日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

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

發(fā)布時(shí)間:2025/4/5 数据库 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql重连,连接丢失:The last packet successfully received from the server--转载 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

原文地址: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的時(shí)候,添加屬性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>

參考

  • MySQL reconnect issues

?

附錄分析

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/

轉(zhuǎn)載于:https://www.cnblogs.com/davidwang456/p/4425913.html

總結(jié)

以上是生活随笔為你收集整理的mysql重连,连接丢失:The last packet successfully received from the server--转载的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 欧美一级片免费在线观看 | 日韩福利在线 | 日韩aaaaaa| 五月婷婷网站 | 成人精品一区二区三区电影 | 日韩美女性生活 | 亚洲一区二区三区 | 午夜片在线观看 | 91视频一区二区 | 国产91精品高潮白浆喷水 | 大桥未久av在线播放 | 成人一区二区三区四区 | 国产欧美一区二区三区精华液好吗 | 亚洲91网| 免费精品视频 | 成人第一页| 五月婷婷激情在线 | 久久久成人精品一区二区三区 | 成人影片在线播放 | a久久久久久| 五月婷网站 | 日韩二三区 | 啪啪导航 | 日韩少妇av | 婷婷九九 | 久久黄色小说 | 日韩免费一区二区三区 | 黄色短视频在线观看 | 美女脱光内衣内裤 | 国产精品刘玥久久一区 | 影音先锋亚洲天堂 | 少妇被躁爽到高潮 | 精品在线免费观看视频 | 亚洲无限av | 国产女人18毛片 | 狠狠狠狠狠狠干 | 六月婷婷七月丁香 | 免费日本视频 | 捅肌肌 | 狠狠干超碰 | 亚洲精品高清视频在线观看 | 色呦呦一区二区 | 日本三级吃奶头添泬无码苍井空 | 麻豆视频在线观看免费 | 在线观看国产一区二区三区 | 台湾男男gay做爽爽的视频 | 丰满人妻妇伦又伦精品国产 | 狠狠爱视频 | 久草一区二区 | 九九九精品视频 | 成人永久免费视频 | 亚洲经典视频 | 天天综合91 | 99re8在线精品视频免费播放 | 国产女优在线播放 | 国产男人天堂 | 国产成人精品亚洲日本在线观看 | 武林美妇肉伦娇喘呻吟 | 激情都市一区二区 | 国产手机av在线 | 亚洲欧洲成人精品久久一码二码 | 国产精品免费一区二区区 | 99久久精品免费看国产免费软件 | 国产女人精品视频 | 小柔好湿好紧太爽了国产网址 | 青娱乐最新官网 | 黄色大网站 | www.com黄色| 爱福利视频网 | 国产在线不卡 | 99夜色| 九九热精品视频在线播放 | 椎名由奈av一区二区三区 | 亚洲av成人精品午夜一区二区 | 五月天激情丁香 | 野花视频在线免费观看 | 国产精品免费一区 | 亚洲国产麻豆 | 精品人人妻人人澡人人爽牛牛 | 超碰日日夜夜 | 自拍视频在线播放 | 俺来也俺也啪www色 欧洲一区二区视频 | 不卡二区 | 新红楼梦2005锦江版高清在线观看 | 欧美日韩精品一区二区在线观看 | 亚洲作爱视频 | 人人舔人人爽 | 97久久久 | 国产视频在线观看免费 | 欧美日韩一级大片 | 免费国偷自产拍精品视频 | 日韩黄色a级片 | 四虎永久地址 | 亚洲av成人无码网天堂 | 一级a毛片免费观看久久精品 | 国产人妖av | av网站天堂 | 成人人伦一区二区三区 | 国产免费的av |