mysql link fail_链接数据库报错(Communications link failure)之解决篇,

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:Communicationslinkfailure Thelastpacketsentsuccessfullytotheserverwas0millisecondsago.Thedriverhasnotreceivedanypacketsfromtheserver. 这个是最近我遇到的错误,就是一个普通的jdbc链接,

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

这个是最近我遇到的错误,就是一个普通的jdbc链接,(弄了我2天时间,主要系电脑的区别问题)

上网看了好多方法,主要由于数据库的内置问题引起:

mysql5将其连接的等待时间(wait_timeout)缺省为8小时。

解决方法:

1,先开mysql,输入 show

global variables like 'wait_timeout'; 这句,就会显示出时间了,

mysql﹥ show global variables like 'wait_timeout';

+---------------+---------+

| Variable_name | Value |

+---------------+---------+

| wait_timeout | 28800 |

+---------------+---------+

1 row in set (0.00 sec)

解释:Mysql服务器默认的“wait_timeout”是8小时,也就是说一个connection空闲超过8个小时,Mysql将自动断开该connection。这就是问题的所。将会造成上面的异常。

2

set global wait_timeout=604800;

3

set global interactive_timeout=604800;

输入以上两句就可以解决这个问题了,

注意: 每个人的电脑不同,我在网上看了好多帖子,关于这个问题,略叼啊,什么都有得说的,为什么人家配置完还是不行,

重启mysql服务,先会生效,有的电脑就算重启mysql的服务都不会生效的,然后就只有重启了,我的就是这样,就算修改完mysql的配置都是不行的,最后重启电脑才连接上了数据库,我切底无语。

为何

详细介绍看:http://zeusami.iteye.com/blog/1112827

f68f2add0b68e4f9810432fce46917b7.png

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值