mysql重连,连接丢失:The last packet successfully received from the server--转载

LSF实践专题(15):LSF队列优先级以及抢占功能初探 在LSF暂停作业时,会向作业发送一个SIGTSTP信号,并且将作业状态变成SSUSP(system suspend),表示被系统暂停,这时,最好是作业的应用能够捕获和处理SIGTSTP信号,否则,即使在LSF中,作业会被认为暂停了,并且释放了slots资源,但是在实际OS中,作业进程仍然在继续,并且不会释放CPU等计算资源。是指LSF自动将低优先级作业暂停(suspend),将空余出来的资源交给高优先级队列中的作业使用,等到高优先级队列的作业结束后,再将被暂停的作业恢复(resume)并继续运行。 阅读详情

今天发生了一个前所未有错误,大恐。慌忙查阅,得此方案,记录之

mysql重连,连接丢失:The last packet successfully received from the server--转载

原文地址:http://nkcoder.github.io/blog/20140712/mysql-reconnect-packet-lost/

1.1 错误信息:

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 20,820,001 milliseconds ago.  The last packet sent successfully to the server was 20,820,002 milliseconds ago. 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.
		at sun.reflect.GeneratedConstructorAccessor29.newInstance(Unknown Source) ~[na:na]
		at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.7.0_51]
		at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[na:1.7.0_51]
		at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) ~[mysql-connector-java-5.1.29.jar:na]
		at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1129) ~[mysql-connector-java-5.1.29.jar:na]
		at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3988) ~[mysql-connector-java-5.1.29.jar:na]
		at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2598) ~[mysql-connector-java-5.1.29.jar:na]
		at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778) ~[mysql-connector-java-5.1.29.jar:na]
		at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2828) ~[mysql-connector-java-5.1.29.jar:na]
		at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:5372) ~[mysql-connector-java-5.1.29.jar:na]
		at com.mchange.v2.c3p0.impl.NewProxyConnection.setAutoCommit(NewProxyConnection.java:881) ~[c3p0-0.9.1.1.jar:0.9.1.1]
		at org.quartz.impl.jdbcjobstore.AttributeRestoringConnectionInvocationHandler.setAutoCommit(AttributeRestoringConnectionInvocationHandler.java:98) ~[quartz-2.2.1.jar:na]

1.2 解决方法

- 如果使用的是JDBC,在JDBC URL上添加?autoReconnect=true,如:

jdbc:mysql://10.10.10.10:3306/mydb?autoReconnect=true

- 如果是在Spring中使用DBCP连接池,在定义datasource增加属性validationQuery和testOnBorrow,如:

<bean id="vrsRankDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="${jdbc.driverClassName}" />
    <property name="url" value="${countNew.jdbc.url}" />
    <property name="username" value="${countNew.jdbc.user}" />
    <property name="password" value="${countNew.jdbc.pwd}" />
    <property name="validationQuery" value="SELECT 1" />
    <property name="testOnBorrow" value="true"/>
</bean>

- 如果是在Spring中使用c3p0连接池,则在定义datasource的时候,添加属性testConnectionOnCheckin和testConnectionOnCheckout,如:

<bean name="cacheCloudDB" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="driverClass" value="${jdbc.driver}"/>
    <property name="jdbcUrl" value="${cache.url}"/>
    <property name="user" value="${cache.user}"/>
    <property name="password" value="${cache.password}"/>
    <property name="initialPoolSize" value="10"/>
    <property name="maxPoolSize" value="${cache.maxPoolSize}"/>
    <property name="testConnectionOnCheckin" value="false"/>
    <property name="testConnectionOnCheckout" value="true"/>
    <property name="preferredTestQuery" value="SELECT 1"/>
</bean>

参考

 

附录分析

When a c3p0-proxied Connection throws an SQLException, c3p0 examines  
the Exception and the Connection to make a judgement about whether  
the problem implies that the Connection should no longer be included  
in the pool. c3p0 tests the Connection, and if the test fails,  the  
Connection will be excluded from the pool.

What c3p0 is telling you here is that a Connection that previously  
signalled an error and then failed a Connection test is still in use,  
and has signalled another error. From c3p0's perspective, this is a  
non-issue, it just means c3p0 doesn't have to do any kind of checks  
or notifications, the Connection is already gone as far as the pool  
is concerned. But c3p0 wonders why you'd still be using such a  
Connection, and warns you about it.

Usually, if a client continues to use a Connection that c3p0 has  
correctly identified as broken, all further uses will provoke such an  
exception, and the fix is to close the Connection and start over when  
an application's Connection turns out to be dead. But, by the error  
you're getting, it looks like your Connection is still live and okay  
-- it's clearly communicating with the database. So, the issue is,  
why did c3p0 deem the Connection dead if it is not?

If you turn on DEBUG level logging (relevant loggers would be  
com.mchange.v2.c3p0.impl.NewPooledConnection,  
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool, and  
com.mchange.v2.c3p0.impl.DefaultConnectionTester, unless you've  
defined your own ConnectionTester), you can trace the testing and  
invalidation of Connections, and try to understand why Connections  
that seem okay are testing as broken. That will give you better  
information about what's going on.

That said, the only cost of this behavior is disconcerting warning  
messages and somewhat faster churn of Connections through the pool.  
c3p0 is erring on the side of caution -- it has reason to believe a  
Connection is bad, so it's been excluded from the pool. It'd be nice  
to know why apparently good Connections are failing Connection tests,  
but if it is an infrequent occurrence, it's very little to worry  
about. (If it's happening a lot, you should track it down.)
原文地址:http://sourceforge.net/p/c3p0/mailman/message/18310863/
YOLOv5改进 | 低照度检测 | 2024最新改进CPA-Enhancer链式思考网络(适用低照度、图像去雾、雨天、雪天) 本文给大家带来的2024.3月份最新改进机制,由CPA-Enhancer: Chain-of-Thought Prompted Adaptive Enhancer for Object Detection under Unknown Degradations论文提出的CPA-Enhancer链式思考网络CPA-Enhancer通过引入链式思考提示机制,实现了对未知退化条件下图像的自适应增强。该方法的核心在于能够利用CoT提示对图像退化进行动态分析和适应,从而显著提升物体检测性能。 阅读详情

相关推荐

【密码专栏】超强进阶:PLONK VS Groth16(上)

前言 前文《天冷了,干了这碗“零知识证明”鸡汤》对「零知识证明学习」作了一个形象化的比喻:炖鸡汤。那么本系列的主要内容可以简单概括为《论高压锅炖鸡汤的一百种方法》之方法二。在学会了“清炖鸡汤”之后,不如来一口“阿胶鸡汤”补补脑细胞吧! 正如鸡汤不同风味之间各具千秋,不同的zk-SNARK方案也各有所长。zk-SNARK方案可以被分为【通用】与【非通用】zk-SNARK,PLONK与Groth16分别是其中的典型代表。通过本系列,我们将对PLONK算法内容作简要介绍,并指出PLONK和Groth16算法思路上

Hyperchain的博客 1805

Springboot项目启动:报错The last packet sent successfully to the server was 0 milliseconds ago

解决方法:修改MySQL数据库连接后面未为如下即可 ?useSSL=false&useUnicode=true&characterEncoding=utf-8&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai

java李阳勇的博客 2721

微信支付V2,jsapi支付拉起收银台报错:调用支付JSAPI缺少参数:total_fee

拉起收银台报错

m0_54355172的博客 3873

Spring The last packet sent successfully to the server was 0 milliseconds ago.

连接数据库遇到这种问题:Spring The last packet sent successfully to the server was 0 milliseconds ago.

m0_50989151的博客 804

嵌入式C开发必备:用Cursor规则搞定代码风格检查(附Pikachu项目实战)

本文以Pikachu开源项目为例,详细介绍了如何利用Cursor的AI代理规则系统,为嵌入式C开发项目配置一套完整的代码风格检查与规范执行方案。通过实战演示,指导开发者创建项目级规则,实现命名、格式、硬件抽象层及驱动开发的自动化规范,从而提升代码一致性、可维护性和团队协作效率。

weixin_29181861的博客 602

【IPAM】Netbox docker模式版本升级

NETBOX 是一个开源的网络资源管理系统,主要用于管理 IP 地址、机架、设备、接口等网络资源信息。下面是 NETBOX 的功能、优点和缺点的详细介绍。

u012153104的博客 1330

解决异常:“The last packet sent successfully to the server was 0 milliseconds ago. ”的办法

springboot+mysql+mybatis-plus springboot启动失败,提示异常The last packet sent successfully to the server was 0 milliseconds ago 解决方法:任务管理器重启mysql服务

yishibaiqianwan3的博客 798

AutoLISP 学习 (一)

AutoLISP基本语法结构、语法 以括号组成表达式,左右括号一定要成对,单、双引号也要成对,例如: (defun c:hello() (princ "\nHello world!") (prin1) ) 表达式格式:(函数名 操作数 操作数 …),例如: (setq p1 (list 0 0)) (setq p2 (list 10 10)) (setq p3 (list 20 20)) ;;; CAD中画直线,经过p1 p2 p3 (command "LINE" p1 p2 p3 ""

m0_54575622的博客 2123

解决异常:“The last packet sent successfully to the server was 0 milliseconds ago. ”的办法;及Linux网络ping不通得问题

2com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 3 The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. 宿主机ping不通Linux

qq_21128741的博客 4万+

SAP 打印输出中 `#` 字符替代日文汉字的根本原因与全面解决方案

只要认清设备类型 / 字符集 / 字体三角关系,并合理利用PDFUCSWINCF或 UPE + URDT,LP01里那些恼人的就会彻底消失,日文汉字将在纸面与 PDF 中如预览一样完美呈现。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 818

Android 14.0 Launcher3定制化之最近任务的全部清除由左边移到下边显示

在最近14.0的系统rom产品开发中,在Launcher3的定制化开发中,在最近任务列表中,发现点击recents最近任务键后 显示的全部清除按键在左边 由于是横屏的产品显示在左边不太合理 所以要求显示在下边比较合理,所以要从Launcher3的显示流程来解决这个问题

安卓兼职framework和app工程师的博客 767

SpringBoot整合Mybatis Bug已解决:The last packet sent successfully to the server was 0 milliseconds ago

今天在学习SpringBoot整合Mybatis时,浏览器请求一直没有得到响应: ![在这里插入图片描述](https://img-blog.csdnimg.cn/20201026114441107.png#pic_center) 控制台显示信息: ![在这里插入图片描述](https://img-blog.csdnimg.cn/2020102611553459.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text

ray2580的博客 2128

基于锁相环的高精度频率分频器simulink建模与仿真

在现代电子系统中,高精度频率分频器扮演着至关重要的角色。它能够提供精确的频率参考,广泛应用于通信、仪器仪表、航空航天等领域。基于锁相环的高精度频率分频器具有结构简单、性能稳定等优点,成为了研究的热点。

平时工作较为繁忙,私信消息一般晚上回复,谢谢大家~~ 776

java mysql重连_mysql重连,连接丢失:The last packet successfully received from the server–转载...

1.1 错误信息:Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 20,820,001 milliseconds ago. The last packet sent successfully t...

weixin_35773740的博客 626

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

mysql the last_mysql重连,连接丢失:The last packet successfully received from the server--转载...

1.1 错误信息:Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 20,820,001 milliseconds ago. The last packet sent successfully t...

weixin_42298164的博客 320

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

mysql重连,连接丢失:The last packet successfully received from the server

问题原因: 其实上面的提示中已经给出了一部分的简要说明,简单来说就是: 程序启动时,在跟DB首次交互时,获得了相应的DB Connection资源,从而进行正常的DB读写操作。但是在下次进行DB读写时(我的定时任务本身设置的时间间隔是24小时),应用程序认为这个连接是可以正常使用的(程序执行过一次之后没有退出,这个连接从来并没有被释放掉),但实际上,这个连接已经坏掉了,因为Mysql本身已经

凹凸的专栏 3万+

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

mysql重连,连接丢失 The last packet successfully received from the

mysql重连,连接丢失 The last packet successfully received from the

qq_44945073的博客 952

mysql重连,连接丢失:The Last Packet Successfully Received From the Server

源:http://nkcoder.github.io/ 评: 1.1 错误信息: Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 20,820,001 milliseconds ago....

mauersu 834

Communications link failure The last packet successfully received from the server was 2,687,887 mi

使用场景: 1.tomcat jdbc连接池 2.mysql数据库 3.隔一段时间后就会出现 Communications link failureThe last packet successfully received from the server was 2,687,887 milliseconds ago之类的错误提示,出现这个问题的原因是使用了无效数据库连接 spring....

johnhuster的专栏 3135
上一篇: 基于SSM框架权限系统的开发
下一篇: 浏览器关闭,session真的失效了吗?
Yuwen_forJava
博客等级 码龄9年 28粉丝 90原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值