Grails 3 Automatic Reconnect with MS Sql Server

巧了我就是萌 提交于 2019-12-20 04:55:11

问题


I am developing a web application on Grails 3.2.2 with spring boot and hibernate and MS SQL Server as a backend database. I want my application to reconnect with the database automatically whenever SQL server comes back after a restart or any other issue.

This is how my application.yml file database-related properties look like:

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

And this is the JTDS library, I'm using in build.gradle file:

compile group: 'net.sourceforge.jtds', name: 'jtds', version: '1.3.1'

So, with these configurations too, my application is unable to reconnect to the MS SQL Server automatically after the restart of SQL Server service.


回答1:


I found an issue when using the Javamelody plugin, compile 'org.grails.plugins:grails-melody-plugin:1.72.0' in build.gradle.

Once I commented this out it resolved reconnection issues to our database. May not be the same issue for you but perhaps for others it maybe.



来源:https://stackoverflow.com/questions/49027576/grails-3-automatic-reconnect-with-ms-sql-server

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