Communications link failure,The last packet successfully received from the server was *** millisecon
来源:互联网 发布:网络球机需要几根网线 编辑:程序博客网 时间:2024/06/05 11:49
最近做测试,发现Mysql 过一段时间会无法连接,导致数据库数据不一至,极其郁闷。
下面是转一哥门的
使用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将自动断开该连接,而连接池却认为该连接还是有效的(因为并未校验连接的有效性),当应用申请使用该连接时,就会导致上面的报错。
1.按照错误的提示,可以在JDBC URL中使用autoReconnect属性,实际测试时使用了autoReconnect=true&failOverReadOnly=false,不过并未起作用,使用的是5.1版本,可能真像网上所说的只对4之前的版本有效。
2.没办法,只能修改MySQL的参数了,wait_timeout最大为31536000即1年,在my.cnf中加入:
[mysqld]
wait_timeout=31536000
interactive_timeout=31536000
重启生效,需要同时修改这两个参数。
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/cau99/archive/2009/12/11/4987760.aspx
- Communications link failure,The last packet successfully received from the server was *** millisecon
- Communications link failure,The last packet successfully received from the server was *** millisecon
- Communications link failure,The last packet successfully received from the server was × millisecon..
- Communications link failure,The last packet successfully received from the server was *** millisecon
- Communications link failure,The last packet successfully received from the server was *** millisecon
- 错误Communications link failure,The last packet successfully received from the server was的解决方法
- MYSQL Communications link failure,The last packet successfully received from the server was
- mysql 报错Communications link failure,The last packet successfully received from the server was × mill
- 数据库学习笔记(十)Communications link failure,The last packet successfully received from the server was
- MySQL: Communications link failure,The last packet successfully received from the server
- Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received
- Communications link failure:The last packet sent successfully to the server was 0 milliseconds ago.
- (2)Mysql ----- The last packet successfully received from the server was *** millisecond ago.The
- The last packet successfully received from the server was XXX seconds ago
- mysql The last packet successfully received from the server was XXX seconds ago
- 彻底解决"The last packet successfully received from the server was * milliseconds ago"问题
- The last packet successfully received from the server was 78,682,686 milliseconds ago
- The last packet successfully received from the server was 30,516,920 milliseconds ago.
- 使用asp.net mvc 创建一个blog发布系统
- 设计模式文摘
- live555 soure filter
- C static
- Hang up voice calls(转)
- Communications link failure,The last packet successfully received from the server was *** millisecon
- 1
- C++运算优先级
- cairngorm3.0
- 分页功能的java实现
- 线程
- JS创建HTML标签
- ps切片的使用
- SQL SERVER中OVER子句与聚集函数的结合使用