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 ...
随机推荐
- 【Android基础】listview控件的使用(2)-------继承自ListActivity的普通listview
由于listview在android控件中的重要性,所以android为我们直接封装了一个类ListviewActivity,直接将listview封装在了activity之中,在本篇中,我将介绍在L ...
- 会员卡管理系统技术解析(十八)Timer定时监听
会员卡管理系统技术解析(十八)Timer定时监听 在web应用中,有时候客户须要一些定时程序.不须要客户自己去操作.而是由应用程序自行触发(代理)运行某些操作. 这个时候监听与定时器的配合使用就基本能 ...
- docker 真实---安装基本映像 (一)
浸泡了几天的官方网站,正确docker有了更好的理解.准备着手建立一个公司的开发和测试环境,包含java.python. 环境介绍 首先说明一下我的环境 2物理server(以后简称为主机) 主机A配 ...
- redis内存管理代码的目光
zmalloc.h /* zmalloc - total amount of allocated memory aware version of malloc() * * Copyright (c) ...
- 【面试】【Spring常见问题总结】【09】
81.SimpleJdbcTemplate SimpleJdbcTemplate类也是基于JdbcTemplate类,但利用Java5+的可变參数列表和自己主动装箱和拆箱从而获取更简洁的代码. Sim ...
- Spring : 征服数据库 (两)
本节介绍Spring和ORM集成框架.尽管Hibernate在开源ORM 社区很受欢迎.但是,本文将MyBatis案例解说.也MyBatis和Hibernate好坏是没有意义的,主要看实际需求,有兴趣 ...
- C++ tree(1)
建立与基本操作 .有关二叉树的相关概念,这里不再赘述,假设不了解二叉树相关概念,建议先学习数据结构中的二叉树的知识点 准备数据 定义二叉树结构操作中须要用到的变量及数据等. #define MAXLE ...
- Node.js和PHP运行机制对比
为什么要用node.js它又有什么优势呢?一个新的技术被大家喜爱那么它就必然有它的优势,那么下面我们就来简单把它和php做一个对比 1 . Node.js 他用的是JavaScript引擎,那么注定它 ...
- css3制作一个漂亮的按钮
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFMAAAA4CAIAAAAO41POAAAGWklEQVRogeWabWwTdRzH/8EwMb6Q69
- SQL Server 2008 /SQL Server 2008 R2 配置数据库邮件
原文:SQL Server 2008 /SQL Server 2008 R2 配置数据库邮件 从2005开始,就引入了"数据库邮件"功能.并且取代SQLMail.原有SQLMail ...