MySQL: Communications link failure,The last packet successfully received from the server
来源:互联网 发布:36槽30kw发电机数据 编辑:程序博客网 时间:2024/05/22 05:22
使用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
重启生效,需要同时修改这两个参数。
补充: 在centos 上 查找 /etc/my.cnf,即可
- MySQL: Communications link failure,The last packet successfully received from the server
- 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 *** 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的解决方法
- 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
- 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
- mysql The last packet successfully received from the server was XXX seconds ago
- mysql重连,连接丢失:The last packet successfully received from the server
- mysql重连,连接丢失:The last packet successfully received from the server
- mysql重连,连接丢失:The last packet successfully received from the server
- mysql重连,连接丢失:The last packet successfully received from the server
- 票据贴现额度恐遭挤压 价格成本难免上扬
- windows下nessus5离线验证安装
- 在eclipse中空心J标志的工程
- RedHat linux配置yum本地资源
- GLUT场景漫游(一)
- MySQL: Communications link failure,The last packet successfully received from the server
- UIAlertView中加入UITextField及Username/Password彈跳視窗 分类: iOS UIAlertView 代码实现
- Java中static、final用法小结
- linux文件字符替换
- android 程序中如何导入第三方jar包(包括android系统程序)
- view组件draw,onDraw,dispatchDraw
- SubJgrid
- C语言的编译链接过程的介绍
- 三个方法让你成为更好的程序员