Communications link failure,The last packet successfully received from the server was *** millisecon

编程入门 行业动态 更新时间:2024-10-25 18:25:42

Communications link <a href=https://www.elefans.com/category/jswz/34/1767734.html style=failure,The last packet successfully received from the server was *** millisecon"/>

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年,在myf中加入:

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

更多推荐

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

本文发布于:2024-02-12 14:13:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1688125.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:failure   packet   Communications   link   server

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!