Microsoft JDBC驱动程序的'自动重新连接'JDBC连接属性 [英] 'Auto Reconnect' JDBC connection property for Microsoft JDBC Driver

查看:128
本文介绍了Microsoft JDBC驱动程序的'自动重新连接'JDBC连接属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有jdbc连接属性使用Microsoft JDBC Driver for SQL Server自动重新连接到SQL Server 2012。我没有找到它,我正在使用hikari cp进行连接池。 Plz让我知道,如果连接丢失,是否有更好的方式重新连接数据库。我使用hikari cp使用spring-hibernate连接到使用Microsoft JDBC Driver的SQL Server 2012. 解析方案

connectionTestQuery 在此设置配置文件



另外引用文档作为关于此参数的警告词:


connectionTestQuery如果您的驱动程序支持JDBC4,我们强烈建议
建议不要设置此属性。这是针对不支持JDBC4 Connection.isValid()API的传统数据库
。这是
查询,它将在连接从池中获得
之前执行,以验证与数据库的连接仍然是
活动。再次尝试在没有此属性的情况下运行该池,如果您的驱动程序不符合JDBC4以允许您知道
,HikariCP
将记录错误。默认值:无


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 .

解决方案

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

这篇关于Microsoft JDBC驱动程序的'自动重新连接'JDBC连接属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆