Communications link failure的解决办法
使用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属性避免该错误。
后来查了一些资料,才发现遇到这个问题的人还真不少,
大部分都是使用连接池方式时才会出现这个问题,短连接应该很难出现这个问题。
这个问题的其中一个原因:
MySQL服务器默认的“wait_timeout”是28800秒即8小时,意味着如果一个连接的空闲时间超过8个小时,
MySQL将自动断开该连接,而连接池却认为该连接还是有效的(因为并未校验连接的有效性),
当应用申请使用该连接时,就会导致上面的报错。
修改MySQL的参数,wait_timeout最大为31536000即1年,在my.cnf中加入:
my.cnf位置在MySQL安装目录下:
[mysqld]
wait_timeout=31536000interactive_timeout=31536000
重启mysql服务生效,需要同时修改这两个参数。
Communications link failure的解决办法相关推荐
- 连接数据库报错com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure的解决方法
控制台报错 Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure com. ...
- 解决——》CommunicationsException:Communications link failure
推荐链接: 总结-->[Java] 总结-->[Mysql] 总结-->[Spring] 总结-->[SpringBoot] 总结--& ...
- Communications link failure 解决方法 !!!
Communications link failure 解决方法 最近在使用mybatis逆向生成的时候遇到了link failure的问题, 这里记录解决方法 文章目录 Communications ...
- Communications link failure解决
启动程序时报错Communications link failure The last packet sent successfully to the server was 0 millisecond ...
- [08S01] Communications link failure报错解决
通过ide连接数据库或者 启动java项目的时候数据库连接不上报错 [08S01] Communications link failure The last packet sent successfu ...
- Connection timed out: connect; Communications link failure
今天过来启动自己的项目出现如下的问题: Communications link failure The last packet sent successfully to the server was ...
- Communications link failure错误(亲测有效)
当时我的报了这个错误,我就从网上搜了解决这类问题的办法,找到的大多数是说:MySQL服务器默认的"wait_timeout"是8小时,数据库超过8小时没用,链接超时了. 让修改这两 ...
- 连接mysql异常Communications link failure
连接mysql 数据库的时候出现这个异常Communications link failure,原因:如果在wait_timeout秒期间内,数据库连接(java.sql.Connection)一直处 ...
- 【数据库问题】[08S01] Communications link failure
[08S01] Communications link failure The last packet sent successfully to the server was 0 millisecon ...
最新文章
- 聊聊flink的AscendingTimestampExtractor
- 蓝牙杂散超标_杂散发射
- [CSS]滤镜用法(1)
- 电脑公司win11旗舰版32位镜像v2021.07
- redis主从配置及无法连接处理
- 验证身份证合法性的js
- php岗位专业技能,PHP简历专业技能怎么写
- Cannot change version of project facet Dynamic Web Module to 2.5解决方案
- 发家致富:爬取双色球信息并统计
- 使用python代码调用三汇语音卡硬件拨打电话
- 修改Office 2016安装路径的方法
- JavaEE中的依赖性——依赖查找
- 惠普HP Deskjet 1180c 打印机驱动
- 计算机自动弹回桌面,win10玩无主之地2自动返回桌面怎么办
- 微信聊天服务器端口号怎么查,如何查看服务的端口号
- 数字电路课设_电子抢答器
- 西湖大学张岳老师实验室招收博士、研究助理、实习生啦~
- 学术沙龙-写好综述-读书笔记分享和讨论
- 就算砸下1300亿造车,苹果颠覆行业也有点难
- Flutter Icons 内置图标库,全套Material图标