[英]JDBC Connection get lost after some idle time
I am getting a communication link failure exception while executing some MySQL queries after some time.一段时间后,我在执行一些 MySQL 查询时遇到通信链路故障异常。 I am using the SQL connection object of package groovy.sql. I am using the SQL connection object of package groovy.sql. The application works perfectly fine if I browse the application continuously but it won't work if I browse the application after some ideal time.如果我连续浏览该应用程序,该应用程序可以正常工作,但如果我在某个理想时间后浏览该应用程序,它将无法正常工作。
Below are the details:以下是详细信息:
Code snippet:代码片段:
def dataSource = grails.util.Holders.applicationContext.getBean('dataSource')
Sql sql = new Sql(dataSource);
sql.rows(query)
Datasource properties:数据源属性:
properties:
maxActive: 50
maxIdle: 25
minIdle: 5
initialSize: 5
maxWait: 10000
removeAbandoned: true
removeAbandonedTimeout: 400
logAbandoned: true
minEvictableIdleTimeMillis: 1800000
timeBetweenEvictionRunsMillis: 1800000
numTestsPerEvictionRun: 3
testOnBorrow: true
testWhileIdle: true
testOnReturn: true
validationQuery: "SELECT 1"
Thanks in advance.提前致谢。
I would try to put timeBetweenEvictionRunsMillis to -1 (deactivated).我会尝试将timeBetweenEvictionRunsMillis 设置为 -1(停用)。 If it fixes your issue, it means you have a connection pool management issue.如果它解决了您的问题,则意味着您遇到了连接池管理问题。
What (if any) exception is being thrown?抛出了什么(如果有的话)异常? You might consider looking at https://www.ibm.com/docs/en/mpf/8.0.0?topic=sources-handling-stale-connections您可能会考虑查看https://www.ibm.com/docs/en/mpf/8.0.0?topic=sources-handling-stale-connections
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.