druid不能close mysql连接_druid长时间无操作无法保持连接!!

在纯原生JAVA项目中使用Druid作为MySQL连接池时遇到问题,即使配置了testWhileIdle=true,也无法避免因10小时无操作导致的连接断开。配置包括初始连接数、最小连接数、最大连接数等参数,但当超过MySQL默认的8小时无活动断开时间,查询仍会抛出SQLException,提示最后的成功通信时间过久。
摘要由CSDN通过智能技术生成

纯原生JAVA项目中,Druid作为MySQL连接池时(MySQL默认为8小时没操作就断开),测试场景为10小时不进行任何查询,就算配置了testWhileIdle=true,也不能保持连接,配置如下:

source.mysql.url=jdbc:mysql://127.0.0.1:3306/xxx

source.mysql.username=root

source.mysql.password=xxx

source.mysql.driver=com.mysql.jdbc.Driver

source.mysql.initialSize=10

source.mysql.minIdle=10

source.mysql.maxActive=100

source.mysql.maxWait=60000

source.mysql.timeBetweenEvictionRunsMillis=10000

source.mysql.minEvictableIdleTimeMillis=300000

source.mysql.validationQuery=select 1

source.mysql.testWhileIdle=true

source.mysql.testOnBorrow=false

source.mysql.testOnReturn=false

source.mysql.removeAbandoned=true

source.mysql.removeAbandonedTimeout=1800

source.mysql.logAbandoned=false

source.mysql.poolPreparedStatements=false

source.mysql.maxPoolPreparedStatementPerConnectionSize=20

source.mysql.filters=stat,wall

10小时后查询,报:

java.sql.SQLException: The last packet successfully received from the server was 63,920,837 milliseconds ago. The last packet sent successfully to the server was 63,920,858 milliseconds ago.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值