解决——》CommunicationsException:Communications link failure
推荐链接:
总结——》【Java】
总结——》【Mysql】
总结——》【Spring】
总结——》【SpringBoot】
总结——》【MyBatis、MyBatis-Plus】
解决——》CommunicationsException:Communications link failure
- 1、操作
- 2、现象
- 3、原因
- 4、解决
- 1)执行sql调大wait_timeout的值
- 2)修改/etc/my.cnf调大wait_timeout的值
1、操作
正常查询数据库
2、现象
通信异常:通信链路故障
从服务器成功接收的最后一个数据包是66734毫秒前。最后一个成功发送到服务器的数据包是66732毫秒前。
2022-11-16 17:59:05.129 ERROR [10.122.139.93] [http-nio-8917-exec-9] [house-cms-0a7a8b5d-463497-1034] com.alibaba.druid.filter.logging.Slf4jLogFilter.statementLogError [line=149 ] : {conn-10020, pstmt-34465} execute error. SELECT id,title,dept_name,emp_code,emp_name,emp_phone,password,emp_mail,status,sort,type,remark,login_ip,login_time,is_delete,update_user,create_user,version,create_time,update_time FROM tb_user WHERE is_delete=0AND (emp_code = ?) limit 0,1
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failureThe last packet successfully received from the server was 66,734 milliseconds ago. The last packet sent successfully to the server was 66,732 milliseconds ago.at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:423)at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990)at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3562)at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3462)at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3905)at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2495)at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1903)at com.mysql.jdbc.PreparedStatement.execute$original$Qo3qQCn7(PreparedStatement.java:1242)at com.mysql.jdbc.PreparedStatement.execute$original$Qo3qQCn7$accessor$m73OheMY(PreparedStatement.java)at com.mysql.jdbc.PreparedStatement$auxiliary$qLH27S5e.call(Unknown Source)at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:86)at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java)at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3461)at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440)at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3459)at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440)at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3459)at com.alibaba.druid.wall.WallFilter.preparedStatement_execute(WallFilter.java:626)at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3459)at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:167)at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:497)
3、原因
Mysql的连接等待时间(wait_timeout)默认8小时。在wait_timeout时间内,mysql的连接(connection)处于等待状态,一旦超过这个时间,mysql就会关闭。但是在我们的项目中的连接池中仍存在合法的connection,当你的程序需要再次访问数据库时,就会出现以上异常,但是再重新访问,又能正常从数据库中获取到数据。
# 连接等待时间,单位为秒
# 默认8小时 = 28800s,windows最大24天,linux最大365天
show global variables like 'wait_timeout';
4、解决
1)执行sql调大wait_timeout的值
# mysql重启之后又会恢复成8小时
set global wait_timeout=1814400;
2)修改/etc/my.cnf调大wait_timeout的值
# 重启mysql服务之后生效,大约21天
wait_timeout=1814400
解决——》CommunicationsException:Communications link failure相关推荐
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 数据库报错
-- 查询mysql 数据库链接空闲时间持有最大空闲时间,单位为秒 SHOW VARIABLES WHERE VAriable_name = 'interactive_timeout'; -- 会出现 ...
- Cause com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:Communications link failure 问题解决 报错
Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 问题解决 Cau ...
- mac之idea连接MySQL数据库报com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
项目场景: 最近入手了一台MacBookPro(谨慎尝试,用惯了windos后使用感具别扭,需要大量时间来适应),下载了最新的idea和最新的mysql8.0.23,然后开始了漫长而艰辛的开始,各种没 ...
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
昨天数据库做了一些改动,早上再打开的项目的时候就出现了这样的问题 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communicat ...
- 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个数据库又没问题. ...
- com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure 数据库jdbc连接异常,数据库连接异 ...
- 连接数据库报错com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure的解决方法
控制台报错 Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure com. ...
- Druid 连接池 报错 com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
场景赘述 早晨查看项目前一天的实际运行日志,发现了 一个Springboot项目中的druid 连接池和 mysql 产生了异常信息,重连暂并未对系统产生影响 下面是具体报错信息: com.mysql ...
最新文章
- 寻找隐形冠军 支付宝、微信用得那么溜,可谁知道背后有一名“上海功臣
- 三维的对象表示---OpenGL二次曲面和三次曲面函数
- Django框架(6.django后台管理/通过后台对数据表的增删改)
- Web.xml配置Error Page不能够转发的问题分析及解决
- 数据科学与大数据技术的案例_作为数据科学家解决问题的案例研究
- Binder远程转本地
- CSDN的常用文本设置(字体大小红色)
- 外键为','(逗号)拼接ID,连接查询外键表ID
- python自动化六--操作mysql,redis,发送邮件,EXCEL,MD5加密
- 设置元素的高度为百分比,结果不起作用的解决方法
- 【元胞自动机】基于matlab保守策略元胞自动机三车道(不开放辅路,软件园影响)交通流模型【含Matlab源码 1294期】
- 速达软件无法打开帐套数据库/一般性网络错误
- 1#组合数学初步——排列与组合之加法原理、乘法原理
- API接口错误码设计最佳实践
- 猜游戏程序java_java猜字游戏
- python聊天室_python聊天室
- 如何学计算机打字,如何学习最快的电脑打字如何为电脑新手快速学习打字
- 基于改进的 CASA 模型反演30m分辨率NPP
- 【操作系统】某寺庙,住着一个老和尚和若干小和尚,有一个水缸,由小和尚提水入缸供老和尚饮用。水缸可以容纳10桶水,水取自同一口井中,由于水井口窄,每次只能容纳一个水桶取水,水桶总数为3个。每次往水缸中倒
- 计算机拒绝目标用户,由于目标计算机主动拒绝,无法建立连接127.0.0.1:8082