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.

时间: 2024-11-06 09:48:48

myql_链接丢失异常_mybaits _等框架_报错_The last packet successfully的相关文章

python框架Scrapy报错TypeError: &#39;float&#39; object is not iterable解决

原因是:Twisted版本高了. 解决办法: 只要把Twisted库降级到16.6.0即可: 1 pip3 install Twisted==16.6.0 2 3 注:Twisted16.6.0安装后,会自动卸载高版本的Twisted python框架Scrapy报错TypeError: 'float' object is not iterable解决

学习React前端框架,报错 &#39;React&#39; must be in scope when using JSX react/react-in-jsx-scope

问题 import react from 'react'  改成  import React from 'react'   小写 react  改成 React 学习React前端框架,报错 'React' must be in scope when using JSX react/react-in-jsx-scope 原文地址:https://www.cnblogs.com/BensonHai/p/9952156.html

iOS AFNetworking 2.6.0框架导入报错解决方法

最近手动导入AFNetworking 2.6.0框架时发现Xcode报如下3个错误: 1. Use of undeclared identifier ‘kSecFormatUnknown‘ 2. Use of undeclared identifier ‘kSecItemPemArmour‘ 3. Implicit declaration of function ‘SecItemExport‘ is invalid in C99 查询后发现, 解决方法有如下两种: 第一种: 通过CocoaPod

eclipse 导入框架app 报错

Android导入源码packages 中的apps出错 下载完源码后再linux 中编译框架中的app模块是不会出错的,但是加载到eclipse就会有很多错误. Google 给用户提供的SDK 都是阉割版本的 无法使用隐藏的API,如果想要使用系统API 比如import android.os.AsyncResult; 首先需要下载源码,然后编译.编译完成后 在out/target/common/obj/JAVA_LIBRARIES/framework_intermediates 中把cla

框架服务器报错

1. tomcat6 无法启动 ,求助! 编程语言 C:\Documents and Settings\IBM>catalina.bat run Using CATALINA_BASE: D:\Program Files\apache-tomcat-6.0.16\ Using CATALINA_HOME: D:\Program Files\apache-tomcat-6.0.16\ Using CATALINA_TMPDIR: D:\Program Files\apache-tomcat-6.0

ThinkPHP CI codeignitor 框架 服务器 报错:Object not found! 可能是htaccess的问题

开启重写,将下面的放在.htaccess中 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]

RocketMQ_问题_启动控制台console报错,connect to &lt;null&gt; failed

配置如图所示: 问题如图所示: 明明配置了nameserver参数为啥还是connect to null呢? 我的rocketmq部署在CentOS7虚拟机上,原来是没关闭防火墙,执行:systemctl stop firewalld.service,关闭防火墙,即可搞定 好久没处理防火墙的问题,忽视这里了 原文地址:https://www.cnblogs.com/rocker-pg/p/10403697.html

解决mysql安装报错:无法启动此程序,因为计算机丢失MSVCP120.dll

问题一: 因为装的是新系统,所以遇到mysql启动报错:无法启动此程序,因为计算机丢失MSVCP120.dll 后来参考这篇文章https://blog.csdn.net/huacode/article/details/79557871,完美的得到了解决,原来是电脑上缺乏Visual C++ Redistributable Packages for Visual Studio 2013,去微软官网下载一个即可 问题二: 查询报错: You must reset your password usi

Android学习——R文件丢失异常原因汇总

Console报错:R.java was modified manually! Reverting to generated version! 引言: R文件丢失异常在java开发中是个比较常见的异常,造成这个异常的原因可能非常微小,但是给Android开发者们造成的麻烦可是巨大的,当程序员们费尽千辛万苦,找到自己错在哪里的时候,绝对会对自己的粗心大意而捶胸顿足,哀叹不已. 异常提示: R.java was modified manually! Reverting to generated ve