nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link fai

今天晚上一个财务子系统上线,部署完成后,测试反馈程序会抽风,一会儿正常,一会儿异常,报如下错误:


nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link fai

通过查找资料,可能是wait_timeout设置过小导致的,尝试加大wait_timeout的值后,系统恢复正常。

更改过程如下:

##查看MySQL配置

[email protected]:mysql.sock [finance]>show global variables like ‘wait_timeout‘;

+---------------+-------+

| Variable_name | Value |

+---------------+-------+

| wait_timeout  | 10    |

+---------------+-------+

1 row in set (0.01 sec)

[email protected]:mysql.sock [finance]>show global variables like ‘%interactive_timeout%‘;

+---------------------+-------+

| Variable_name       | Value |

+---------------------+-------+

| interactive_timeout | 28800 |

+---------------------+-------+

##先修改全局的值为300,重启后将恢复原值

[email protected]:mysql.sock [finance]>set global wait_timeout=300;

[email protected]:mysql.sock [finance]>show global variables like ‘wait_timeout‘;

+--------------------------+----------+

| Variable_name            | Value    |

+--------------------------+----------+

| wait_timeout             | 300      |

+--------------------------+----------+

##修改my.cnf,保证MySQL重启后依然生效

[mysqld]

wait_timeout=300

## wait_timeout扩展

MySQL服务器默认的“wait_timeout”默认是28800秒即8小时,意味着如果一个连接的空闲时间超过8个小时,MySQL将自动断开该连接,而连接池却认为该连接还是有效的(因为并未校验连接的有效性),当应用申请使用该连接时,就会导致上面的报错。

解决方法:

修改my.cnf:

[mysqld]

wait_timeout=31536000

interactive_timeout=31536000

将过期时间修改为1年。

Error Log日志如下:

The last packet successfully received from the server was 9,369 milliseconds ago.  The last packet sent successfully to the server was 0 milliseconds ago.
; SQL []; Communications link failure

The last packet successfully received from the server was 9,369 milliseconds ago.  The last packet sent successfully to the server was 0 milliseconds ago.; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 9,369 milliseconds ago.  The last packet sent successfully to the server was 0 milliseconds ago.
at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:98)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
at com.sun.proxy.$Proxy11.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:198)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
at com.sun.proxy.$Proxy12.searchRules(Unknown Source)
at com.tianlian.order.server.finance.service.impl.poundage.WPOSPoundageServiceImpl.searchRules(WPOSPoundageServiceImpl.java:55)
at com.tianlian.order.server.finance.service.impl.poundage.WPOSPoundageServiceImpl$$FastClassBySpringCGLIB$$aec2fff5.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at com.alibaba.druid.support.spring.stat.DruidStatInterceptor.invoke(DruidStatInterceptor.java:72)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
at com.tianlian.order.server.finance.service.impl.poundage.WPOSPoundageServiceImpl$$EnhancerBySpringCGLIB$$db4e378e.searchRules(<generated>)
at com.alibaba.dubbo.common.bytecode.Wrapper0.invokeMethod(Wrapper0.java)
at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:46)
at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:72)
at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53)
at com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:64)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:78)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:60)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:112)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:38)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:108)
at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:84)
at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:170)
at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52)
at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:82)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Error log

时间: 2024-08-07 04:33:29

nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link fai的相关文章

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

启动Tomcat时,发生如下异常: DEBUG resourcepool.BasicResourcePool  - An exception occurred while acquiring a poolable resource. Will retry. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

1.错误描述 [ERROR:]2015-11-05 14:37:52,558 [插入失败] report.service.impl.ReportServiceImpl org.hibernate.exception.JDBCConnectionException: error executing work at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegat

异常解决com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

21:37:08,815 DEBUG BasicResourcePool:1831 - An exception occurred while acquiring a poolable resource. Will retry.com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 数据库报错

-- 查询mysql 数据库链接空闲时间持有最大空闲时间,单位为秒 SHOW VARIABLES WHERE VAriable_name = 'interactive_timeout'; -- 会出现wait_timeout与该参数意思相近,修改时,一起修改 SHOW VARIABLES WHERE VAriable_name = '%timeout'; -- 解决问题 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Commun

mysql 5.1超过默认8小时空闲时间解决办法(错误:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure)

报错: MySQL第二天早上第一次连接超时报错, com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 原因: 上述问题是由mysql5数据库的配置引起的.mysql5将其连接的等待时间(wait_timeout .interactive_timeout)缺省为8小时.在其客户程序中可以这样来查看其值: mysql> show global variables like 'wait

MySQL出现:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Last packet sent to the server was 0 ms ago.

1.首先检查生产环境的机器是否ping的通和telnet的通数据库 2.排查数据库连接的参数 3.看数据量是否很大 参考: http://blog.csdn.net/sclxf/article/details/5775125

mysql 数据库问题com.mysql.jdbc.exceptions.jdbc4.CommunicationsException

本文转自:http://blog.csdn.net/zmzsoftware/article/details/6835604 MySQL第二天早上第一次连接超时报错,解决方法com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link fa

【第一个项目】MySQL第二天早上第一次连接超时报错,解决方法com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:

MySQL第二天早上第一次连接超时报错,解决方法com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Last packet sent to the server was 0 ms ago 最近碰到一个mysql5

Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 78,050,512 milliseconds ago.

今天访问已经架上服务器的网站,报错: Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 78,050,512 milliseconds ago. The last packet sent successfully to the server was 78,050,512 milliseconds ago.