标题: Communications link failure原因分析 [打印本页] 作者: 盛世宏图 时间: 2024-12-3 15:50 标题: Communications link failure原因分析 先附上完整报错,com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure\n\nThe last packet successfully received from the server was 10,004 milliseconds ago. The last packet sent successfully to the server was 10,004 milliseconds ago.
首先在网上搜索,有以下解决方案:
1、在数据库url上加,autoReconnect=true
并不能解决问题
2、猜疑是数据库关闭了空闲时间超过28800秒(8小时)的连接,但上述报错显示10秒前还能成功,故排除这种大概。
而且druid连接池在1.2.6版本以后针对空闲连接有默认探活和剔除机制,会将空闲超过25600秒(7小时)的连接踢出,并默认60s举行一次探活。
3、后来就猜疑存在慢查询,从而导致以上错误,待验证