Last modified:2013-10-08 14:16:47
**********************************************
web网站使用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。
原因:
Mysql服务器默认的“wait_timeout”是8小时(也就是默认的值默认是28800秒),也就是说一个connection空闲超过8个小时,Mysql将自动断开该connection,通俗的讲就是一个连接在8小时内没有活动,就会自动断开该连接。而连接池却认为该连接还是有效的(因为并未校验连接的有效性),当应用申请使用该连接时,就会导致上面的报错。
wait timeout的值可以设定,但最多只能是2147483,不能再大了。也就是约24.85天。
修改方法:MySQL通过my.ini 在
# The TCP/IP Port the MySQL Server will listen on
port=3306下面添加
# this is myown dinifition for mysql connection timeout
wait_timeout=31536000
interactive_timeout=31536000
以上是在网上找到的解决方法,但是一般连接的有效时间不用修改,后来分析了以下问题,发现是由于数据库连接池的一句配置引发的:
<!-- 最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 --> <property name="maxIdleTime" value="0"></property>
由于mysql的连接空闲超过8个小时,所以就关闭了,但是连接池却永不丢弃连接,认为该连接还是有效的(因为并未校验连接的有效性),当应用申请使用该连接时,就会导致上面的报错。
解决方法将value设置为20。
使用数据连接池,如果常常发生连接失效,可以在连接池配置文件中添加连接测试:<house-keeping-test-sql>select 1</house-keeping-test-sql>,及时过滤失效的连接.
相关推荐
Cause com.mysql.jdbc.exceptions.jdbc4.CommunicationsException The last packet successfully received from the server was 47,795,922 milliseconds ago. The last packet sent successfully to the server was...
There are different queuing strategies, and these determine not only the performance of the interconnection network, but also the set of requirements to make them work effectively and their cost....
Wiley.Evolved.Packet.System.The.LTE.and.SAE.Evolution.of.3G.UMTS.Mar.2008.pdf Wiley.Evolved.Packet.System.The.LTE.and.SAE.Evolution.of.3G.UMTS.Mar.2008.pdf Wiley.Evolved.Packet.System.The.LTE.and.SAE....
Evolved.Packet.System.The.LTE.and.SAE.Evolution.of.3G.UMTS.2008
@[Android studio通过jdbc连接mysql基本步骤 以及 遇到的坑“The last packet sent successfully to the server was 0 milliseconds ago”哈哈] 小白第一次发博客哈哈,记录一下这三个晚上来我的悲惨经历以及我成功...
Packet Capturev1.7.2.apkPacket Capturev1.7.2.apkPacket Capturev1.7.2.apk
PacketTracer7.exe
2.查看数据库表创建完成后,我们可以查看数据库表show tables 2.修改表记录2.1 不带条件的update 表名 set 字段名=值, 字段名=值,
此文件用于替代Cisco Packet Tracer 8.2.1.0118的PacketTracer.exe,免去了登录过程,便于使用。 将压缩包文件解压到Cisco Packet Tracer 8.2.1.0118安装文件夹(X:\Program Files\Cisco Packet Tracer\bin)>>更改...
Cisco Packet Tracer 6.0.rar,,,自行百度,我也不知道干啥的
The "ptsaplayer.dll" in the .zip package is the patch to fix the issue that Packet Tracer 7.2.2's PTSAPlayer plugin does not work on Windows 7. Apply the patch will fix the issue. Only users using...
It’s easy to capture packets with Wireshark, the world’s most popular network sniffer, whether off the wire or from the air. But how do you use those packets to understand what’s happening on your ...
我用到的数据库为,mysql数据库5.7版本的 首先自己准备好数据库表 其实我在插入1000万条数据的时候遇到了一些问题,现在先来解决他们,一开始我插入100万条数据时候报错,控制台的信息如下: ...
博文链接:https://zyx19920203.iteye.com/blog/2301226
Cisco Packet Tracer 6.0.zip,带汉化说明,带补丁,完美汉化........................................................................................................................
Cisco Packet Tracer 6.2.rar思科路由模拟器。保证绿色无毒。
Packet.Moodle.JavaScript.Cookbook
资源分类:Python库 所属语言:Python 资源全名:pulumi_packet-3.2.1.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059