jdbc 连接mysql 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.conf中加入:
[mysqld] wait_timeout= interactive_timeout=
重启生效,需要同时修改这两个参数。
jdbc 连接mysql Communications link failure的解决办法的更多相关文章
- 【MySQL】JDBC连接MySQL的一些问题以及解决办法
[MySQL]JDBC连接MySQL的一些问题以及解决办法 http://blog.csdn.net/baofeidyz/article/details/52017047
- Communications link failure的解决办法
使用Connector/J连接MySQL数据库,程序运行较长时间后就会报以下错误: Communications link failure,The last packet successfully r ...
- 解决MySQL连接超时Communications link failure due to underlying exception
最近在用一个MySQL的Java连接池的过程中,连接一晚上不释放,第二天就会造成超时的错误,查了一下原因,原来是因为MySQL默认的空闲等待时间是8个小时,一旦空闲超过8个小时,就会抛出异常.异常文本 ...
- 【Azure 应用服务】App Service 无法连接到Azure MySQL服务,报错:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
问题描述 App Service使用jdbc连接MySQL服务,出现大量的 Communications link failure: com.mysql.cj.jdbc.exceptions.Com ...
- 解决:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure(真实有效)
数据库连接失败 一.例如我在SpringBoot项目中使用了阿里的数据库连接池Driud. 有次在启动的时候,会报这样的错: Caused by: com.mysql.cj.exceptions.CJ ...
- Mysql Communications link failure 问题的解决
问题现象 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last p ...
- Communications link failure异常解决
一,异常现象 com.bill99.inf.ibatis.DBException: queryForList error::sqlId=orgOrderAssetsMapping.queryModel ...
- mysql Communications link failure Last packet sent to the server was X ms ago
想必大家在用MySQL时都会遇到连接超时的问题,如下图所示: 就是这个异常(com.mysql.jdbc.exceptions.jdbc4.Communication***ception:Commun ...
- mysql Communications link failure,C3p0的参数详解
MySQL默认一个连接空闲8小时候就会自动断开,而这时程序以为连接还能使用,然后在使用的时候就会出现Communications link failure异常. 这时需要进行两步设置,有时候只设置My ...
随机推荐
- 【Android Studio】没有先安装JDK
如果没有先安装JDK,安装Android Studio的时候回出现下面这个界面: 请参考我整理的博客文章<JDK的下载.安装和配置>,链接:http://www.cnblogs.com/d ...
- JavaScript & HTML5 Canvas 概览 更新时间2014-0411-1805
HTML Canvas 坐标体系:矩形区域的左上角为坐标原点(0,0),向右为x轴,向下为y轴. 检测浏览器是否支持Canvas(IE系列从IE9开始支持): <!DOCTYPE html> ...
- selenium webdriver python 操作IE浏览器
Step1:下载IEDriverServer 下载路径:http://selenium-release.storage.googleapis.com/index.html 我下载的是2.48版本的IE ...
- 平衡树(AVL)详解
1. 为什么平衡树? 在二叉搜索树(BST,Binary Search Tree)中提到,BST树可能会退化成一个链表(整棵树中只有左子树,或者只有右子树),这将大大影响二叉树的性能. 前苏联科学家G ...
- CCASS四种交收指令
CCASS 提供了4种类型的指令:ATI: Account Transfer Instruction 账户转移指令,用于本券商各个仓位上的转移STI: Stock Segregate Account ...
- Linux用户root忘记密码的解决(unbuntu16.04)
参考: http://www.linuxidc.com/Linux/2012-04/59069.htm http://www.68idc.cn/help/server/linux/2015060735 ...
- 简单md5加密
using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptograph ...
- Linux下生产者与消费者的线程实现
代码见<现代操作系统> 第3版. 为了显示效果,添加了printf()函数来显示运行效果 #include<stdio.h> #include<pthread.h> ...
- php 之 post json 数据
原文链接 http://www.jb51.net/article/27312.htm 最近用到python 与PHP交互,phthon把json数据post给PHP,但在PHP里面$_post获取不到 ...
- 9.2noip模拟试题
题目名称 改造二叉树 数字对 交换 英文名称 binary pair swap 输入文件名 binary.in pair.in swap.in 输出文件名 binary.out pair.out ...