正在进行安全检测...

发布时间:2023-10-01 21:20:16   来源:文档文库   
字号:
百度文库 - 让每个人平等地提升自我
关于MySQLwait_timeout连接超时问题报错解决方案
Mysql服务器默认的“wait_timeout”是8小时【也就是默认的值默认是28800秒】,也就是说一个connection空闲超过8个小时,Mysql将自动断开该connection通俗的讲就是一个连接在8小时内没有活动,就会自动断开该连接。 wait timeout的值可以设定,但最多只能是2147483,不能再大了。也就是约天 所以即使你MySQL通过
# The TCP/IP Port the MySQL Server will listen on port=3306下面添加
# this is myown dinifition for mysql connection timeout wait_timeout= interactive_timeout= 无论超过最大限度多大的数值,只能被MySQL解析为21474832147483天后你的程序该出什么错还是什么错,避免不了的


在说这个错误之前先说明我的项目是通过Hibernate来进行数据库操作的
关于MySQL连接超时问题,估计很多人都遇到过:大致情形都是这样,开发测试时程序都是正常的,一到第二天就出先莫名错误,比如在我的项目中就是定时任务执行,每天凌晨一点执行一次,也就是24小时每隔24小时执行,远远超出了8小时
如果你刚好在数据库超时的第一时间内看到日志记录的话那么,第一次超时发生的错误就是这样的:
ERROR [ - Communications link failure Last packet sent to the server was 0 ms ago. 如果不是第一次超时后执行,以后每次报错就变成嵌套的错误了,就是下面这样:
ERROR [ - No operations allowed after connection was implicitly closed due to underlying exception/error:

** BEGIN NESTED EXCEPTION **

1
百度文库 - 让每个人平等地提升自我
MESSAGE: The last packet successfully received from the server was86395 milliseconds last packet sent successfully to the server was 86395 milliseconds ago, which 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. STACKTRACE: The last packet successfully received from the server was86395 milliseconds last packet sent successfully to the server was 86395 milliseconds ago, which 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. at Method at Source at Source at Source at at at at at at at at at at at at at at at at at at at at at at at at
at
2

本文来源:https://www.2haoxitong.net/k/doc/28328f3eb80d4a7302768e9951e79b89690268f6.html

《正在进行安全检测....doc》
将本文的Word文档下载到电脑,方便收藏和打印
推荐度:
点击下载文档

文档为doc格式