zoukankan      html  css  js  c++  java
  • Communications link failure,The last packet successfully received from the server was *** millisecon

    使用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属性避免该错误。

    后来查了一些资料,才发现遇到这个问题的人还真不少,大部分都是使用连接池方式时才会出现这个问题,短连接应该很难出现这个问题。这个问题的原因:

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

    2. 没办法,只能修改MySQL的参数了,wait_timeout最大为31536000即1年,在my.cnf中加入:

    [mysqld]  
    
    wait_timeout=31536000  
    
    interactive_timeout=31536000  
    • 1

    重启生效,需要同时修改这两个参数。


    Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure  
    [09:49:36.821]  
    [09:49:36.821]Last packet sent to the server was 0 ms ago.  
  • 相关阅读:
    Vue项目中使用Vue-Quill-Editor富文本编辑器插件
    Element-UI中的Cascader 级联选择器高度以及位置问题
    Sublime中同一个文件进行分屏显示
    Oracle的clob数据类型
    查看Nginx版本号的几种方式
    华为路由器EasyNAT&NAT Server
    huawei路由器NAT配置
    15
    14
    13
  • 原文地址:https://www.cnblogs.com/baobeiqi-e/p/9884751.html
Copyright © 2011-2022 走看看