`
m635674608
  • 浏览: 5042464 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

Communications link failure,The last packet successfully received from the serve

    博客分类:
  • java
 
阅读更多

  关于MySQL连接超时问题,估计很多人都遇到过:大致情形都是这样,开发测试时程序都是正常的,一到第二天就出先莫名错误,比如在我的项目中使用了多数据源,其中有一个数据源仅仅供查询使用,所以使用次数很少。当出现了超时错误,一般错误日志如下:
Communications link failure

The last packet successfully received from the server was 510,815 milliseconds ago.  The last packet sent successfully to the server was 0 milliseconds 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
无论超过最大限度多大的数值,只能被MySQL解析为2147483

 

解决方案:

1、按照错误的提示,可以在JDBC URL中使用autoReconnect属性,实际测试时使用了autoReconnect=true&failOverReadOnly=false,不过并未起作用,使用的是5.1版本,可能真像网上所说的只对4之前的版本有效。

 

2、增大mysql的wait_timeout属性值;(起不到实质性作用)

show variables like '%timeout';


3、最好的解决方法,如果使用了c3p0连接池,可以配置idleConnectionTestPeriod 属性,每多少秒检查所有连接池中的空闲连接,把该值设置的小于mysql的wait_timeout值即可。

 

http://blog.csdn.net/liuxiao723846/article/details/45534885

分享到:
评论

相关推荐

    mysql 异常com.mysql.jdbc.CommunicationsException

    本次异常的具体描述为:“Communications link failure due to underlying exception: **BEGINNESTED EXCEPTION** java.io.EOFException STACK TRACE: java.io.EOFException at com.mysql.jdbc.MysqlIO.readFully...

    ## @[Android studio通过jdbc连接mysql基本步骤 以及 遇到的坑“The last packet sent successfully to the server was 0 m

    @[Android studio通过jdbc连接mysql基本步骤 以及 遇到的坑“The last packet sent successfully to the server was 0 milliseconds ago”哈哈] 小白第一次发博客哈哈,记录一下这三个晚上来我的悲惨经历以及我成功...

    解决Cause com.mysql.jdbc.exceptions.jdbc4.CommunicationsException

    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...

    linux 后台日志 mysql 错误异常的解释(推荐)

    The last packet successfully received from the server was 56,201,339 milliseconds ago. The last packet sent successfully to the server was 56,201,339 milliseconds ago. is longer than the server ...

    MySQL与JDBC1

    删除记录则有带条件和不带条件的`DELETE FROM`,需要注意的是,`DELETE`操作不会重置主键自增ID,而`TRUNCATE TABLE`会删除所有记录并重置ID。 查询操作是数据库操作的核心部分,`SELECT`语句用于获取数据。可以...

    融合多个面上光强信息的混合迭代相位恢复算法

    融合多个面上光强信息的混合迭代相位恢复算法

    The BSD Packet Filter A New Architecture for User-level Packet Capture.pdf

    ### BSD Packet Filter (BPF): 新架构下的用户级数据包捕获 #### 概述 本文档探讨了**BSD Packet Filter (BPF)**——一种新型的用户级数据包捕获架构,该架构由Steven McCanne和Van Jacobson在1992年提出,并计划...

    计算机网络第六版答案

    23. The five layers in the Internet protocol stack are – from top to bottom – the application layer, the transport layer, the network layer, the link layer, and the physical layer. The principal ...

    LinuxMint加入域时的错误解决方案.pdf

    LinuxMint加入域时的错误解决方案,包括:DNS_ERROR_BAD_PACKET、ERROR_GEN_FAILURE 0x00000001f、Unable to find ssh binary

    Predictable 802.11 Packet Delivery from Wireless Channel Measurements

    ### 可预测的802.11数据包交付机制基于无线信道测量 #### 摘要与背景 在《可预测的802.11数据包交付机制基于无线信道测量》一文中,作者们提出了一种新颖的方法来解决802.11无线局域网(WLAN)中数据包传输的可...

    Cisco Packet Tracer7.2.2 x64补丁

    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...

    Practical Packet Analysis 3rd Edition

    The Practical Packet Analysis course is perfect for beginners to intermediate analysts, but seasoned pros will probably learn a few useful techniques too. Whether you’ve never capture packets before ...

    Magic Packet(TM)

    This is the release notice for the PCnet Magic Packet(TM) Utility Revision 1.00 software. All files are in DOS FAT format. AMD抯 Magic Packet utility is a convenient tool for system administrators ...

    The journey of a packet through the linux 2.4 network stack

    标题:Linux 2.4网络堆栈中数据包的旅程 描述:本文档详细阐述了在Linux内核2.4.x版本中数据包在网络层的处理流程,与2.2版本相比,由于弃用了全局序列化的下半部,转而采用新的软中断(softirq)系统,整个网络...

    Cisco Packet Tracer7.2.2 x32补丁

    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...

    Cisco Packet Tracer 7.2.2 x32

    Cisco Packet Tracer 7.2.2 removes the Java dependence and makes it easier to use Packet Tracer Skills Assessment (PTSA) and Packet Tracer Media Objects (PTMO) : After installing Packet Tracer 7.2.2...

    Cisco Packet Tracer 7.2.2 x64

    Cisco Packet Tracer 7.2.2 removes the Java dependence and makes it easier to use Packet Tracer Skills Assessment (PTSA) and Packet Tracer Media Objects (PTMO) : After installing Packet Tracer 7.2.2...

Global site tag (gtag.js) - Google Analytics