Communications link failure的解决办法

   今天调试quartz定时任务时出现一个问题:列如我的定时任务是每天00:00:00触发,我修改当前时间为2015-05-20 23:59:30,30秒后就会准时执行,错误是发生在我修改时间以后。时间修改为2015-05-21 23:59:30;30秒后定时任务触发,但是出现了一个异常:

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。

百度了下:

MySQL服务器默认的“wait_timeout”是28800秒即8小时,意味着如果一个连接的空闲时间超过8个小时,MySQL将自动断开该连接,而连接池却认为该连接还是有效的(因为并未校验连接的有效性),当应用申请使用该连接时,就会导致上面的报错。

so:解决方案就是修改mysql的配置文件


# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this 
# file.
#
[mysqld]

wait_timeout=1814400
interactive_timeout=1814400

# The TCP/IP Port the MySQL Server will listen on
port=3306


在[mysqld]

后加上wait_timeout=1814400  
interactive_timeout=1814400

注意一定要都加上,网上说的只加上一句并没有效果;


wait_timeout windows系统最大值是1814400(24天) linux是31536000(一年)

加上后保存重启mysql服务

mysql> show variables like 'wait_timeout';
+---------------+---------+
| Variable_name | Value   |
+---------------+---------+
| wait_timeout  | 1814400 |
+---------------+---------+
1 row in set

问题解决

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值