Connection timed out: connect; Communications link failure
今天过来启动自己的项目出现如下的问题:
Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
百度了一下,原因如下:
使用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中加入:
[mysqld]
wait_timeout=31536000
interactive_timeout=31536000
重启生效,需要同时修改这两个参数。
但是如何找到my.cnf文件呢?又找了半天
转载于:https://www.cnblogs.com/bystudy/p/6655146.html
Connection timed out: connect; Communications link failure相关推荐
- Solving a “communications link failure” with jdbc and mysql :Cannot connect to database server Commu
当出现: Cannot connect to database server Communications link failure 错误时,可以考虑下面的文章: http://stackoverfl ...
- mac之idea连接MySQL数据库报com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
项目场景: 最近入手了一台MacBookPro(谨慎尝试,用惯了windos后使用感具别扭,需要大量时间来适应),下载了最新的idea和最新的mysql8.0.23,然后开始了漫长而艰辛的开始,各种没 ...
- Mysql异常之Communications link failure
前天线上出现数据数据抖动,收到大量异常告警,都要疯了,数据库出现大量异常,肯定第一件事就是看下数据库监控数据,发现有一个从分片执行时间有一个50多秒的操作,这里肯定有问题了,第一时间找了dba,经过排 ...
- 【数据库问题】[08S01] Communications link failure
[08S01] Communications link failure The last packet sent successfully to the server was 0 millisecon ...
- Rejecting re-init Communications link failure
@[TOC](Rejecting re-init on previously-failed class java.lang.Class<com.mysql.cj.MysqlType>: j ...
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 数据库报错
-- 查询mysql 数据库链接空闲时间持有最大空闲时间,单位为秒 SHOW VARIABLES WHERE VAriable_name = 'interactive_timeout'; -- 会出现 ...
- Underlying cause: com.mysql.cj.jdbc.exceptions.CommunicationsException : Communications link failure
Hive试图schematool -dbType mysql -initSchema时候报错如下: Metastore connection URL: jdbc:mysql://Desktop ...
- 问题记录——com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure...
最近在搞一个Spring boot + Mybatis + Mysql的项目,用Mybatis访问数据库时,报了如下的错误,先在网上搜索了,试了各种办法都不行, 奇葩的是,连接另外1个数据库又没问题. ...
- KettleError connecting to database: (using class org.gjt.mm.mysql.Driver)Communications link failure
先看错误: 错误连接数据库 [JDOrd] : org.pentaho.di.core.exception.KettleDatabaseException: Error occurred while ...
最新文章
- java hanlp分词_Hanlp分词实例:Java实现TFIDF算法
- java命令行参数工具_Java方法中的参数太多,第8部分:工具
- 机器学习:sklearn数据集与机器学习组成
- linux命令中xargs,在Linux上使用xargs命令的详细教程
- X86汇编语言从实模式到保护模式13:保护模式程序的动态加载和执行
- iOS - OC 与 Swift 互相操作
- yolov3前向传播(三)-- 坐标转换,iou计算,权重加载,图片显示
- python3 抓包 解包_Python结构包,解包
- MCS-51子程序库-1
- C# 调用 dll 文件
- [转] Ubuntu 16.04 RTL8111/8168/8411 不能上网 经常断网解决办法
- 转】用Hadoop构建电影推荐系统
- 如何用分布式Pollard-Rho法对椭圆曲线离散对数问题(ECDLP)进行攻击(下)
- android 顶部弹窗,android显示通知,并在任何应用程序顶部弹出
- 神舟战神Z8-CA5NP,RTX3060怎么样?测评值得买吗?详细性能点评
- Linux 用户管理 文件目录指令 时间日期指令 搜索查找类 解压压缩类
- PAT 1063 计算谱半径
- 学会Zynq(28)SPI控制器简介
- 创业公司失去了增长,你啥也不是!|【常垒·常识】
- 英特尔SST音频驱动导致Windows11电脑蓝屏,驱动人生带来电脑蓝屏解决方案
热门文章
- Auto Encoder再学习
- kettle分批处理大表数据_采用Kettle分页处理大数据量抽取任务
- leetcode —— 523. 连续的子数组和
- Map排序,获取map的第一值,根据value取key等操作(数据预处理)
- VNC实现Windows远程访问Ubuntu 16.04【转载】
- linux驱动线程睡眠,linux驱动中断不能睡眠的原因
- VC2008下使用OpenSSL 1 0 0g 免编译
- Spring框架 注解
- Spring Boot集成Swagger
- 利用建站快速软件包:XAMPP,构建基于winodws平台快速搭建PHP的数据库应用- kimai - 团队时间记录