开发者

Any alternative of mysql_ping for MSSQL?

I'm opening the persistent connection with the DB开发者_如何学Go on MSSQL server over an unstable channel and would like to check the connection status before the transaction starts (it is a daemon service which remains always active).

In case of mysql, postgresql I've used the beautiful mysql_ping and pg_ping to be sure the connection is OK. Any ideas who to accomplish it with M$SQL?


No, there is no built-in function like that for MSSQL. Your best bet would be to run a cheap SQL select such as SELECT GETDATE() NULL on the open connection, catch any SqlException that is thrown, check and re-establish the connection if needed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜