'Auto Reconnect' JDBC connection property for Microsoft JDBC Driver

谁说我不能喝 提交于 2019-12-24 03:08:48

问题


Is there a jdbc connection property to auto reconnect to SQL Server 2012 using Microsoft JDBC Driver for SQL Server. I don't find it and I am using hikari cp for connection pooling . Plz let me know if there is a better way to reconnect to DB if connection lost . I am using spring-hibernate with hikari cp to connect to SQL Server 2012 using Microsoft JDBC Driver .


回答1:


Take a look at the connectionTestQuery setup at this config file.

Also quoting the Documentation as a word of caution about this parameter:

connectionTestQuery If your driver supports JDBC4 we strongly recommend not setting this property. This is for "legacy" databases that do not support the JDBC4 Connection.isValid() API. This is the query that will be executed just before a connection is given to you from the pool to validate that the connection to the database is still alive. Again, try running the pool without this property, HikariCP will log an error if your driver is not JDBC4 compliant to let you know. Default: none



来源:https://stackoverflow.com/questions/31968690/auto-reconnect-jdbc-connection-property-for-microsoft-jdbc-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!