针对数据库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的更多相关文章

  1. 解决Java程序连接mysql数据库出现CommunicationsException: Communications link failure错误的问题

    一.背景 最近在家里捣鼓一个公司自己搭建的demo的时候,发现程序一启动就会出现CommunicationsException: Communications link failure错误,经过一番排 ...

  2. 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 ...

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

    -- 查询mysql 数据库链接空闲时间持有最大空闲时间,单位为秒 SHOW VARIABLES WHERE VAriable_name = 'interactive_timeout'; -- 会出现 ...

  4. mysql Communications link failure,C3p0的参数详解

    MySQL默认一个连接空闲8小时候就会自动断开,而这时程序以为连接还能使用,然后在使用的时候就会出现Communications link failure异常. 这时需要进行两步设置,有时候只设置My ...

  5. Communications link failure的解决办法

    使用Connector/J连接MySQL数据库,程序运行较长时间后就会报以下错误: Communications link failure,The last packet successfully r ...

  6. Communications link failure报错的处理

    一.报错的问题: 测试环境在做压力测试的时候爆出错误 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications l ...

  7. 解决MySQL连接超时Communications link failure due to underlying exception

    最近在用一个MySQL的Java连接池的过程中,连接一晚上不释放,第二天就会造成超时的错误,查了一下原因,原来是因为MySQL默认的空闲等待时间是8个小时,一旦空闲超过8个小时,就会抛出异常.异常文本 ...

  8. jdbc 连接mysql Communications link failure的解决办法

    使用Connector/J连接MySQL数据库,程序运行较长时间后就会报以下错误: Communications link failure,The last packet successfully r ...

  9. 【错误】: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 ...

  10. 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 ...

随机推荐

  1. linux常用的命令之一chmod

    用权限 : 所有使用者 使用方式 : chmod [-cfvR] [--help] [--version] mode file... u 表示该档案的拥有者,g 表示与该档案的拥有者属于同一个群体(g ...

  2. SQL 从入门到 DBA 删库跑路

    SQL 从入门到 DBA 删库跑路 一.基础 人员信息表: ID 姓名 性别 出生 婚否 学历 工资 工会 35009449 孙xx 男 1978-2-17 未婚 中专 3000 TRUE 35000 ...

  3. 油田 (Oil Deposits UVA - 572)

    题目描述: 原题:https://vjudge.net/problem/UVA-572 题目思路: 1.图的DFS遍历 2.二重循环找到相邻的八个格子 AC代码: #include <iostr ...

  4. 数据库Mysql的学习(七)-自定义函数和流程控制

    DELIMITER // (设置结束符 其实我也不太明白为啥要这样 记住就行把) CREATE FUNCTION ym_date(mydate DATE) (创建函数 函数名字(参数)) ) (指定函 ...

  5. Notes of the scrum meeting before publishing(12.19)

    meeting time:18:30~20:30p.m.,December 19th,2013 meeting place:3号公寓一层 attendees: 顾育豪                  ...

  6. 异常概念和处理机制,try-catch-finally,throw和throws,自定义异常

    异常概念和处理机制 什么是异常? 所谓异常就是指在程序运行的过程中发生的一些不正常事件.(如除0溢出,数组下标越界,所要读取的文件不存在); 异常导致的后果? Java程序的执行过程中如出现异常事件, ...

  7. 策略模式,ASP.NET实现

    策略模式,ASP.NET实现 using System; using System.Collections.Generic; using System.Linq; using System.Web; ...

  8. iOS-修改导航栏文字字体和颜色

    //修改导航栏文字字体和颜色 nav.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[RGBColor co ...

  9. iOS-获取webView的高度

    - (void)webViewDidFinishLoad:(UIWebView *)wb{ //方法1 CGFloat documentWidth = [[wb stringByEvaluatingJ ...

  10. Qt语言家(Qt Linguist)更新翻译报错-Qt5.9-MinGW

    版权声明:若无来源注明,Techie亮博客文章均为原创. 转载请以链接形式标明本文标题和地址: 本文标题:Qt语言家(Qt Linguist)更新翻译报错-Qt5.9-MinGW     本文地址:h ...