Druid之连接空闲超时数据库连接不上

druid 是一个用于 Java 的高效数据库连接池,它提供了强大的监控和扩展功能。

空闲等待超时

Java
Caused by:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:The last packet successfully received from the server was 65,699,330 milliseconds ago. The last packet sent successfully to the server was 65,699,330 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem. 

mysql数据库等待超时时间(wait_timeout)是28800,也就是8小时,而druid连接池参数max-wait是30000

连接空闲超时问题的原因通常与连接池和数据库服务器之间的配置不匹配有关。当连接池中的连接长时间处于空闲状态时,数据库服务器可能会关闭这些空闲连接以节省资源。这种情况下,连接池可能仍然认为这些连接是有效的,但实际上数据库服务器已经释放了它们。

以下是引发连接空闲超时问题的一些可能原因:

服务器端的 wait_timeout 设置较低:数据库服务器会在连接空闲一段时间后关闭它们。如果服务器的 wait_timeout 参数设置得较低,连接池中的空闲连接可能在被使用前就已被服务器关闭。

连接池配置不合理

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值