myql_链接丢失异常_mybaits _等框架_报错_The last packet successfully
mysql 8小时问题的解决方法
Use Hibernate + MYSQL database development, link timeout problem:
com.mysql.jdbc.CommunicationsException: The last packet successfully received from the server was58129 seconds ago.The last packet sent successfully to the server was 58129 seconds ago, which is longer than the server configured value of 'wait_timeout'. You should consider either expiring and / or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector / J connection property 'autoReconnect = true' to avoid this problem.
Checked and the original problem is the mysql timeout if the connection idle for 8 hours (8 hours, no database operations), mysql will automatically disconnect to restart the tomcat.
The solution:
One. If you do not hibernate, then adding in the connection url parameter: autoReconnect = true
jdbc.url = jdbc: mysql: / / ipaddress: 3306/database? autoReconnect = true & autoReconnectForPools = true
Two. With hibernate, then add the following attributes:
<property name="connection.autoReconnect"> true </ property>
<property name="connection.autoReconnectForPools"> true </ property>
<property name="connection.is-connection-validation-required"> true </ property>
III. If still using c3p0 connection pool:
<property name="hibernate.c3p0.acquire_increment"> 1 </ property>
<property name="hibernate.c3p0.idle_test_period"> 0 </ property>
<property name="hibernate.c3p0.timeout"> 0 </ property>
<property name="hibernate.c3p0.validate"> true </ property>
IV. The worst solution
Using the Connector / J MySQL database connection, the program will run a long time after the reports the following error:
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.
One error will prompt you to change wait_timeout or use the Connector / J's autoReconnect property to avoid the error.
Then check out some information, only to find people who experience this problem quite a lot, mostly when using connection pooling will appear this way, short connection should be very difficult to have this problem. The cause of the problem:
MySQL Server default "wait_timeout" is 28,800 seconds or 8 hours, means that if a connection idle time exceed 8 hours, MySQL will automatically disconnect the connection, and connection pool is that the connection is still valid (because the school did not test the effectiveness of the connection), when the application when applying for the connection, it will lead to the above error.
1. In accordance with the error prompt, you can use the autoReconnect JDBC URL attribute, the actual test used autoReconnect = true & failOverReadOnly = false, but did not work, use the 5.1 version, you may really like the Internet before talking about only 4 version of the force.
2. No way, can only modify the parameters of the MySQL, wait_timeout a maximum of 31536000 that is 1 year, add in my.cnf:
[Mysqld]
wait_timeout = 31536000
interactive_timeout = 31536000
Restart effect, you need to modify these two parameters simultaneously.
myql_链接丢失异常_mybaits _等框架_报错_The last packet successfully的更多相关文章
- 【干货】YUM安装PHP 7版本后,增加phalcon框架的报错解决
目录 1.yum安装php 7.x版本,此处部署7.3版本 2.安装phalcon框架 2.1.PHP版本依赖关系 2.2.编译phalcon扩展模块 2.3.增加扩展文件 3.部署phalcon遇到 ...
- spring mvc 框架启动报错:nested exception is java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal 解决办法
今天准备将以前自己搭建的一个框架拿出来用一下,结果发现启动报错:nested exception is java.lang.NoClassDefFoundError: org/w3c/dom/Elem ...
- 关于laravel框架分页报错的问题
因为laravel框架有自己的分页封装,所以与其他框架相比laravel框架的分页的实现要方便的多 只要分别在php脚本与视图中使用 $data=DB::table('index_pic')-> ...
- 日志框架整合报错Class path contains multiple SLF4J bindings.
在进行SSM框架的日志框架统一管理时,报错Class path contains multiple SLF4J bindings 如下图 意思是类路径下包含重复的SLF4J绑定,然后给出了重复的两个全 ...
- 2 _ 基本框架 _ 检测VMX环境
VT 是先开为大,谁先开谁上层,谁上层 谁权限大. 1 判断是否支持 VMX intel 白皮书 第3卷 传入 参数eax =1, 返回值 ecx 的第5位 = 1 则 surpported VMX. ...
- springmvc+thymeleaf搭建框架启动报错
最近项目开发需要用到thymeleaf前端界面模板引擎,所以提前了解学习一下,但是在框架搭建好了之后启动tomcat一直提示如下错误: org.springframework.beans.factor ...
- iOS AFNetworking 2.6.0框架导入报错解决方法
最近手动导入AFNetworking 2.6.0框架时发现Xcode报如下3个错误: 1. Use of undeclared identifier ‘kSecFormatUnknown‘ 2. Us ...
- python基于Django框架编译报错“django.core.exceptions.ImproperlyConfigured”的解决办法?
下面是我具体遇到的问题和解决方法: 错误详细信息: django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_IND ...
- RocketMQ_问题_启动控制台console报错,connect to <null> failed
配置如图所示: 问题如图所示: 明明配置了nameserver参数为啥还是connect to null呢? 我的rocketmq部署在CentOS7虚拟机上,原来是没关闭防火墙,执行:systemc ...
随机推荐
- 编译hibernate源代码
1)安装gradle,gradle是一个类似maven的构建工具 2)安装gitclient. 从网址 https://github.com/hibernate/hibernate-orm 上clon ...
- swift 笔记 (十二) —— 下标
下标 swift同意我们为 类.结构体,枚举 定义下标,以更便捷的方式訪问一大堆属性.比方Array和Dictionary都是结构体,swift的project师已经为这两个类型提供好了下标操作的代码 ...
- 皮尔逊相似度计算的例子(R语言)
编译最近的协同过滤算法皮尔逊相似度计算.下顺便研究R简单使用的语言.概率统计知识. 一.概率论和统计学概念复习 1)期望值(Expected Value) 由于这里每一个数都是等概率的.所以就当做是数 ...
- T-Sql(一)简单语法
原文:T-Sql(一)简单语法 Sql Server是鄙人学习的第一种数据库,对Sql Server有一种特别的情感,下面就说一下Sql Server的简单语法,适用初学者. 1,创建数据库creat ...
- 集差集 哈希表 比较数据库的照片和server画面上,将server垃圾上的图片删除
SSH 骨架code: public String deleRubbishAd(){ int deleADcount = 0; rubbishADtp = configDao.rubbishADtp( ...
- Oracle 11g 的PL/SQL函数结果缓存
模拟Oracle性能诊断艺术做了两个试验样品.书上说的不承担RELIES_ON.果缓存的失效操作(result_cache RELIES_ON(test1,test2)).试验证明不正确,函数f1() ...
- 小牟Andorid下面MD5具体实现的思路总结
Android的开发往往需要一定数目demo 从今起MD5一些加密算法提取物 看看是如何实现的 首先,我们必须明确为什么加密? 1 数据安全处理 2 防止数据窃取 3 有效的避免恶意攻击 4 保证文件 ...
- JAVA运行程序代码段
我记得那时候刚毕业.学习JAVA恐惧是这里,它是关于JAVA称号.我总是不正确.如今,这最后审查.看了好半天.得赶紧把刚才学习到的那点东西记下来. 一.关于static的代码段运行顺序 运行结果例如以 ...
- SenchaTouch2.3.1 正在使用listpaging以及pullrefresh插入 分页演示样品做
实际上本实施例是相对简单的.自定义PullRefreshFn插头继承Ext.plugin.PullRefresh. 主要是其附加refreshFn下拉监控事件. listpaging么改动.再将这两个 ...
- Cocos2d-x 游戏植入广告(百度插屏)
DEMO下载:http://download.csdn.net/detail/oyangyufu/7652803 1.声明Activity <!-- 声明百度的Activity --> & ...