设为首页 加入收藏

TOP

mysql:Communications link failure解决
2015-11-21 01:54:24 来源: 作者: 【 】 浏览:1
Tags:mysql:Communications link failure 解决
mysql: Communications link failure解决
?
使用Connector/J连接MySQL,程序运行较长时间后就会报以下错误:?
?
Communications link failure,The last packet successfully received from the server was *** millisecond ago.The last packet successfully sent to the server was *** ?millisecond ago。?
?
其中错误还会提示你修改wait_timeout或是使用Connector/J的autoReconnect属性避免该错误。?
?
MySQL服务器默认的“wait_timeout”是28800秒即8小时,意味着如果一个连接的空闲时间超过8个小时,MySQL将自动断开该连接,而连接池却认为该连接还是有效的(因为并未校验连接的有效性),当应用申请使用该连接时,就会导致上面的报错。?
?
解决办法有两个:?
?
一是修改my.cnf:
?
wait_timeout=31536000 ?
interactive_timeout=31536000 ?
?
将过期时间修改为1年。?
?
二是在连接URL上添加参数:&autoReconnect=true&failOverReadOnly=false?
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Oracle中插入特殊字符:&和'.. 下一篇对Oracle并行的误解2--其实会锁全..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: