Communications link failure
针对数据库Communications link failure的错误,可以理解为有两种策略解决:
策略1(推荐):
数据池配置 <property name="minEvictableIdleTimeMillis" value="28800" />属性,和数据库变量wait_timeout一致。
策略2:
数据池配置
<!-- testWhileIdle会定时校验numTestsPerEvictionRun个连接,只要发现连接失效,就将其移除再重新创建-->
<property name= "testWhileIdle" value="true" />
<!-- 从池中取连接的时候,发现当前连接失效,再创建一个连接供当前查询使用-->
<property name= "testOnBorrow" value="false" />
<!-- 连接在return给pool时,是否提前进行validate操作-->
<property name= "testOnReturn" value="false" />
<!-- 测试连接是否有效的sql-->
<property name= "validationQuery" value="select 1" />
<!-- 检查连接池中空闲的连接的频率:毫秒-->
<property name= "timeBetweenEvictionRunsMillis" value="30000" />
<!-- 每次检查空闲连接的个数-->
<property name= "numTestsPerEvictionRun" value="30" />
一套属性,定期检查连接,发现无效的则关闭。
策略3:
修改MySQL的参数,wait_timeout最大为31536000即1年,在my.cnf中加入:
[mysqld]
wait_timeout=31536000(1年)259200(3天:个人推荐)
interactive_timeout=31536000
重启生效,需要同时修改这两个参数。
!!!需要重启
Communications link failure的更多相关文章
- 解决Java程序连接mysql数据库出现CommunicationsException: Communications link failure错误的问题
一.背景 最近在家里捣鼓一个公司自己搭建的demo的时候,发现程序一启动就会出现CommunicationsException: Communications link failure错误,经过一番排 ...
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 解决办法
09:00:30.307 [http-8080-6] ERROR org.hibernate.transaction.JDBCTransaction -JDBC begin failed com.my ...
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 数据库报错
-- 查询mysql 数据库链接空闲时间持有最大空闲时间,单位为秒 SHOW VARIABLES WHERE VAriable_name = 'interactive_timeout'; -- 会出现 ...
- mysql Communications link failure,C3p0的参数详解
MySQL默认一个连接空闲8小时候就会自动断开,而这时程序以为连接还能使用,然后在使用的时候就会出现Communications link failure异常. 这时需要进行两步设置,有时候只设置My ...
- Communications link failure的解决办法
使用Connector/J连接MySQL数据库,程序运行较长时间后就会报以下错误: Communications link failure,The last packet successfully r ...
- Communications link failure报错的处理
一.报错的问题: 测试环境在做压力测试的时候爆出错误 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications l ...
- 解决MySQL连接超时Communications link failure due to underlying exception
最近在用一个MySQL的Java连接池的过程中,连接一晚上不释放,第二天就会造成超时的错误,查了一下原因,原来是因为MySQL默认的空闲等待时间是8个小时,一旦空闲超过8个小时,就会抛出异常.异常文本 ...
- jdbc 连接mysql Communications link failure的解决办法
使用Connector/J连接MySQL数据库,程序运行较长时间后就会报以下错误: Communications link failure,The last packet successfully r ...
- 【错误】:Could not open JDBC Connection for transaction; nested exception is: Communications link failure;The last packet sent successfully to the server was 1 milliseconds ago
# #错误日志 2016-11-10 16:19:20,834 ERROR [org.quartz.core.JobRunShell] - Job DEFAULT.jobtask threw an u ...
- Oozie时出现Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure?
不多说,直接上干货! 问题详情 [hadoop@bigdatamaster oozie--cdh5.5.4]$ bin/ooziedb.sh create -sqlfile oozie.sql -ru ...
随机推荐
- hihocoder刷题 扫雷游戏
题目1 : 扫雷游戏 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 给定一个N × N的方格矩阵,其中每个格子或者是'*',表示该位置有一个地雷:或者是'.',表示该位 ...
- CSP201509-2:日期计算
引言:CSP(http://www.cspro.org/lead/application/ccf/login.jsp)是由中国计算机学会(CCF)发起的"计算机职业资格认证"考试, ...
- Memcache的客户端连接系列(三) C++
关键词: Memcached C++ 客户端 声明:本文并非原创,转自华为云帮助中心的分布式缓存服务(Memcached)的用户指南.客户端连接方法通用,故摘抄过来分享给大家. C++客户端示例 ...
- UVa 455 - Periodic Strings - ( C++ ) - 解题报告
1.题目大意 求一个长度不超过80的字符串的最小周期. 2.思路 非常简单,基本就是根据周期的定义做出来的,几乎不需要过脑. 3.应该注意的地方 (1) 最后输出的方式要注意,不然很容易就PE了.不过 ...
- (转载)IE8+兼容经验小结
本文分享下我在项目中积累的IE8+兼容性问题的解决方法.根据我的实践经验,如果你在写HTML/CSS时候是按照W3C推荐的方式写的,然后下面的几点都关注过,那么基本上很大一部分IE8+兼容性问题都OK ...
- [leetcode-779-K-th Symbol in Grammar]
On the first row, we write a 0. Now in every subsequent row, we look at the previous row and replace ...
- [leetcode-748-Largest Number At Least Twice of Others]
In a given integer array nums, there is always exactly one largest element. Find whether the largest ...
- 【转】NodeJS on Nginx: 使用nginx反向代理处理静态页面
最近OurJS后台已经从纯node.js迁移到了Nginx+NodeJS上来了,感觉性能提升了不少,特与大家分享. Nginx ("engine x") 是一个高性能的 HTTP ...
- nginx 添加的配置信息
使用logrotate管理Nginx日志配置如下: [root@vm-10-129-93-51 nginx]# vi /etc/logrotate.d/nginx /letv/log/nginx/*. ...
- 《剑指Offer》题一~题十
一.赋值运算符函数 题目:如下为类型CMyString的声明,请为该类型添加赋值运算符函数. class CMyString { public: CMyString(char *pData = nul ...