mysql the last_mysql The last packet successfully received from t

mysql服务器最近老是报错,内容如下:

The last packet successfully received from the server was 65,502,275 milliseconds ago.  The last packet sent successfully to the server was 65,502,276 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.

主要的意思是:: 数据库有长连接,由于长时间没有使用,并且空闲时间超过了wait_timeout设置的时间。 数据库到了wait_timeout设定的时间,自动释放了链接。

客户端还有这个长连接,客户端使用这个长连接向mysql数据库发送消息,可是这个链接数据库服务器端已经释放了,所以爆出上面的错误.

如果你刚好在数据库超时的第一时间内看到日志记录的话那么,第一次超时发生的错误就是这样的:

ERROR [org.hibernate.util.JDBCExceptionReporter] - Communications link failure

Last packet sent to the server was 0 ms ago.

如果不是第一次超时后执行,以后每次报错就变成嵌套的错误了,就是下面这样:

ERROR [org.hibernate.util.JDBCExceptionReporter] -

No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error:

解决办法:由于项目中代码比较多,查找哪一个长连接没有释放很麻烦,过程如下:(1)查看报错日志的详细信息,看关系到哪一个dao类出现的问题

(2)然后将mysql连接池最大、最小数据设置成3,1.

(3)然后打开3个浏览器,进行操作

(4)发现项目确实很慢,然后详细看了一下代码,确实由于一个地方连接池没有关系,导致链接一直存在,没有释放。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值