MySQL连接超时问题-使用Hibernate和ORM在Tomcat上使Grails应用程序

MySQL连接超时问题-使用Hibernate和ORM在Tomcat上使Grails应用程序,第1张

MySQL连接超时问题-使用Hibernate和ORM在Tomcat上使Grails应用程序

参考本文,您的DBCP连接池中有陈旧的连接,这些连接被 *** 作系统或防火墙静默删除。

解决方案是定义一个验证查询并在实际在应用程序中使用连接之前对连接进行完整性检查。在grails中,这实际上是通过修改 grails-app / conf
/ spring / Resource.groovy
文件并添加以下内容来完成的:

beans = {  dataSource(BasicDataSource) {    //run the evictor every 30 minutes and evict any connections older than 30 minutes.    minEvictableIdleTimeMillis=1800000    timeBetweenEvictionRunsMillis=1800000    numTestsPerEvictionRun=3    //test the connection while its idle, before borrow and return it    testonBorrow=true    testWhileIdle=true    testonReturn=true    validationQuery="SELECT 1"  }}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5019444.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-14
下一篇 2022-11-15

发表评论

登录后才能评论

评论列表(0条)

保存