mysql重连,连接丢失:The last packet successfully received from the server
来源:互联网 发布:阿里云 ecs 建站 教程 编辑:程序博客网 时间:2024/05/22 13:40
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>
0 0
- mysql重连,连接丢失:The last packet successfully received from the server
- mysql重连,连接丢失:The last packet successfully received from the server
- mysql重连,连接丢失:The last packet successfully received from the server
- mysql重连,连接丢失:The last packet successfully received from the server
- mysql重连,连接丢失:The last packet successfully received from the server--转载
- mysql重连,连接丢失:The last packet successfully received from the server--转载
- mysql重连,连接丢失:The last packet successfully received from the server--转载
- mysql重连,连接丢失:The last packet successfully received from the server
- mysql重连,连接丢失:The last packet successfully received from the server
- mysql重连,连接丢失:The last packet successfully received
- MySQL之——重连,连接丢失:The last packet successfully received from the serve
- 【转】mysql重连,连接丢失:The last packet successfully received
- (2)Mysql ----- The last packet successfully received from the server was *** millisecond ago.The
- Spring连接mysql长时间空闲报错:The last packet successfully received from the server was xx millisecond ago...
- mysql The last packet successfully received from the server was XXX seconds ago
- MySQL: Communications link failure,The last packet successfully received from the server
- MYSQL Communications link failure,The last packet successfully received from the server was
- mysql超时:The last packet successfully received from the server was 172,848,658 milliseconds ago.
- 沭阳通过省级生态园林城市初步验收
- oracle 10g standby database 实时应用 redo 数据
- 判断滚动条的滚动方向
- 设置窗口透明
- 避免javascript打开新窗口被拦截
- mysql重连,连接丢失:The last packet successfully received from the server
- 统计某个字符数
- Maven实战(七)——常用Maven插件介绍(上)
- poj 3616 Milking Time dp+树状数组
- How to determine the correct setting for JOB_QUEUE_PROCESSES (Doc ID 578831.1)
- 计算机管理没有mysql服务项的解决方法
- 笔试题:Suggest a simple and fast way to multiply the input integer digit by 7。
- 算法-回溯
- 用直接插入排序法对单链表进行排序