Communications link failure的解决办法
来源:互联网 发布:js两个数相加 编辑:程序博客网 时间:2024/04/30 15:29
使用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将自动断开该连接,而连接池却认为该连接还是有效的(因为并未校验连接的有效性),当应用申请使用该连接时,就会导致上面的报错。
修改MySQL的参数,wait_timeout最大为31536000即1年,在my.cnf中加入:
[mysqld]
wait_timeout=31536000
interactive_timeout=31536000
重启生效,需要同时修改这两个参数。
- Communications link failure的解决办法
- Communications link failure的解决办法
- Communications link failure的解决办法
- Communications link failure的解决办法
- Communications link failure的解决办法
- Communications link failure的解决办法
- Communications link failure的解决办法
- MySql的Communications link failure解决办法
- mysql - Communications link failure的解决办法
- MySql的Communications link failure解决办法
- mysql 中Communications link failure的解决方法
- mysql 中Communications link failure的解决方法
- Mysql Communications link failure 问题的解决
- Communications link failure报错的处理
- Communications link failure
- Communications link failure
- mysql: Communications link failure
- Communications link failure
- AssemblyInfo.cs文件的作用
- oracle函数
- C/C++ 移位运算代替乘除法
- jsp中使用javabean
- poj1021-计算度
- Communications link failure的解决办法
- 我的第十九个C++上机报告(编程序,输出一个乘法口诀表)
- Fedora中linux totem 安装解码器 and yum-remove-with-leave插件问题
- Android 游戏开发之paint画笔
- 服务器数据库系列 - sphinx配置
- 3*4的矩阵,编程序求出其中最大的元素的值,以及所在的行号和列号
- hdu - 4340 - Capturing a country - 树形dp
- 有关ActiveX控件中的DataGrid或ADO Data控件在vc++6.0和VS 版本中的使用
- QQ空间伤感日志_这是一个错误的赌注