Grails 3自动重新连接MS Sql Server [英] Grails 3 Automatic Reconnect with MS Sql Server

查看:123
本文介绍了Grails 3自动重新连接MS Sql Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Spring Boot和Hibernate以及MS SQL Server作为后端数据库在Grails 3.2.2上开发一个Web应用程序.我希望我的应用程序在重新启动或其他任何问题后,只要SQL Server重新出现,都将自动与数据库重新连接.

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.

这是与我的 application.yml 文件数据库相关的属性的样子:

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

这是JTDS库,我在 build.gradle 文件中使用:

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

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

因此,同样使用这些配置,我的应用程序无法在重新启动SQL Server服务后自动重新连接到MS SQL Server.

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

推荐答案

使用Javamelody插件时,在build.gradle中编译org.grails.plugins:grails-melody-plugin:1.72.0时发现了一个问题.

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.

这篇关于Grails 3自动重新连接MS Sql Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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