我正在 Grails 3.2.2 上开发一个 Web 应用程序,使用 spring boot 和 hibernate 以及 MS SQL Server 作为后端数据库。我希望每当 SQL Server 在重新启动或出现任何其他问题后恢复时,我的应用程序都能自动重新与数据库连接。
这就是我的应用程序.yml文件数据库相关属性如下所示:
development:
dataSource:
dbCreate: update
url: jdbc:jtds:sqlserver://machine_host_name:1433/db_name?autoReconnect=true
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
这是我正在使用的 JTDS 库构建.gradle file:
compile group: 'net.sourceforge.jtds', name: 'jtds', version: '1.3.1'
因此,使用这些配置,我的应用程序在 SQL Server 服务重新启动后也无法自动重新连接到 MS SQL Server。
我在使用 Javamelody 插件时发现了一个问题,在 build.gradle 中编译 'org.grails.plugins:grails-melody-plugin:1.72.0' 。
一旦我注释掉它,它就解决了与我们数据库的重新连接问题。对您来说可能不是同一个问题,但对其他人来说可能是这样。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)