- 浏览: 514975 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (563)
- 工作经验 (12)
- 数据库 (13)
- Servlet (10)
- Struts2 (1)
- Spring (25)
- Eclipse (5)
- Hibernate (5)
- Eclips (8)
- HTTP (7)
- J2EE (21)
- EHcache (1)
- HTML (11)
- 工具插件使用 (20)
- JPA (2)
- 杂谈 (17)
- 数据结构与算法 (3)
- Cloud Foundry (1)
- 安全 (10)
- J2SE (57)
- SQL (9)
- DB2 (6)
- 操作系统 (2)
- 设计模式 (1)
- 版本代码管理工具 (13)
- 面试 (10)
- 代码规范 (3)
- Tomcat (12)
- Ajax (5)
- 异常总结 (11)
- REST (2)
- 云 (2)
- RMI (3)
- SOA (1)
- Oracle (12)
- Javascript (20)
- jquery (7)
- JSP自定义标签 (2)
- 电脑知识 (5)
- 浏览器 (3)
- 正则表达式 (3)
- 建站解决问题 (38)
- 数据库设计 (3)
- git (16)
- log4j (1)
- 每天100行代码 (1)
- socket (0)
- java设计模式 耿祥义著 (0)
- Maven (14)
- ibatis (7)
- bug整理 (2)
- 邮件服务器 (8)
- Linux (32)
- TCP/IP协议 (5)
- java多线程并发 (7)
- IO (1)
- 网页小工具 (2)
- Flash (2)
- 爬虫 (1)
- CSS (6)
- JSON (1)
- 触发器 (1)
- java并发 (12)
- ajaxfileupload (1)
- js验证 (1)
- discuz (2)
- Mysql (14)
- jvm (2)
- MyBatis (10)
- POI (1)
- 金融 (1)
- VMWare (0)
- Redis (4)
- 性能测试 (2)
- PostgreSQL (1)
- 分布式 (2)
- Easy UI (1)
- C (1)
- 加密 (6)
- Node.js (1)
- 事务 (2)
- zookeeper (3)
- Spring MVC (2)
- 动态代理 (3)
- 日志 (2)
- 微信公众号 (2)
- IDEA (1)
- 保存他人遇到的问题 (1)
- webservice (11)
- memcached (3)
- nginx (6)
- 抓包 (1)
- java规范 (1)
- dubbo (3)
- xwiki (1)
- quartz (2)
- 数字证书 (1)
- spi (1)
- 学习编程 (6)
- dom4j (1)
- 计算机系统知识 (2)
- JAVA系统知识 (1)
- rpcf (1)
- 单元测试 (2)
- php (1)
- 内存泄漏cpu100%outofmemery (5)
- zero_copy (2)
- mac (3)
- hive (3)
- 分享资料整理 (0)
- 计算机网络 (1)
- 编写操作系统 (1)
- springboot (1)
最新评论
-
masuweng:
亦论一次OutOfMemoryError的定位与解错 -
变脸小伙:
引用[color=red][/color]百度推广中运用的技术 ...
Spring 3 mvc中返回pdf,json,xml等不同的view -
Vanillva:
不同之处是什么??
Mybatis中的like查询 -
thrillerzw:
转了。做个有理想的程序员
有理想的程序员必须知道的15件事 -
liujunhui1988:
觉得很有概括力
15 个必须知道的 Java 面试问题(2年工作经验)
源: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. 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>
参考
MySQL reconnect issues
评:
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>
参考
MySQL reconnect issues
发表评论
-
主从延迟
2019-06-17 16:08 291主从复制原理 主从延 ... -
python脚本连接mysql
2018-02-24 12:18 528文件db #!/usr/bin/python #codi ... -
Shell脚本中执行sql语句操作mysql的5种方法
2018-01-22 21:41 1449源:http://www.jb51.net/article/5 ... -
MySQL Explain详解
2018-01-02 16:42 409源:https://www.cnblogs.com/x ... -
mysql repeatable-read 一次利用间隙锁解决幻读案例
2017-09-18 19:21 550源:http://fucheng.blog.51cto.com ... -
Mysql经mysql连接的空闲时间超过8小时后 MySQL自动断开该连接解决方案
2016-07-06 17:16 2174源:http://www.jb51.net/artic ... -
新安装mysql 第三方工具连接不上问题
2015-08-24 00:25 817源:http://blog.csdn.net/dongdong ... -
CentOS源码编译安装MySQL 5.5.15
2014-11-17 01:38 680源:https://www.centos.bz/2011/09 ... -
Mysql中limit的用法详解
2014-07-17 16:58 822源:http://blog.csdn.net/zhqingyu ... -
Lock wait timeout exceeded
2014-04-23 15:28 943源:http://my.oschina.net/jiaoya/ ... -
Fedora 8下的MySQL源码安装手记
2014-03-18 15:00 424源:http://blog.sina.com.cn/s/blo ... -
MySQL数据库添加一个字段
2014-03-14 11:14 657源:http://hi.baidu.com/pianxicun ... -
mysql查询 分组后前 N条数据
2014-01-17 16:04 1528源:http://www.jb51.net/article/3 ...
相关推荐
Cause com.mysql.jdbc.exceptions.jdbc4.CommunicationsException The last packet successfully received from the server was 47,795,922 milliseconds ago. The last packet sent successfully to the server was...
在这个案例中,C3P0连接池中的某些连接由于长时间空闲而被MySQL服务器断开,但是C3P0连接池并不知道这些连接已经失效,当客户端再次请求这些连接时,就产生了`CommunicationsException`异常。 #### 解决方案 根据...
@[Android studio通过jdbc连接mysql基本步骤 以及 遇到的坑“The last packet sent successfully to the server was 0 milliseconds ago”哈哈] 小白第一次发博客哈哈,记录一下这三个晚上来我的悲惨经历以及我成功...
The last packet successfully received from the server was 56,201,339 milliseconds ago. The last packet sent successfully to the server was 56,201,339 milliseconds ago. is longer than the server ...
代码如下:Lost connection to MySQL server at ‘reading initial communication packet’, system error: 0 很明显这是连接初始化阶段就丢失了连接的错误。 google半天大多是说的注释掉配置文件中 bind-address = ...
【MySQL与JDBC1】是关于使用MySQL数据库和Java JDBC(Java Database Connectivity)进行数据库操作的基础教程。在本文中,我们将深入探讨如何在MySQL中执行常见的数据库管理任务,包括创建和删除数据库、操作数据库...
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 84,371,623 milliseconds ago. The last packet sent successfully to the server was 78,...
融合多个面上光强信息的混合迭代相位恢复算法
远程连接MySQL所遇到的问题以及解决问题方法 在 Linux 系统中,使用 YUM 命令安装 MySQL 后,需要进行一系列的配置以便能够远程连接 MySQL 数据库。以下是解决不能进行远程连接 MySQL 数据库的问题的方法,这些方法...
在IT行业中,数据库操作是日常开发中的重要环节,而MySQL作为广泛应用的关系型数据库,其性能和稳定性至关重要。本文将深入探讨“com.mysql.jdbc.PacketTooBigException: Packet for query is too large (11087 > ...
【MySQL连接错误分析与解决】 在使用MySQL数据库时,可能会遇到“Authentication Failed”错误,这通常意味着客户端在尝试连接数据库时认证失败。错误信息显示“Reading from the stream has failed”,表明在数据...
3、Can’t connect to local MySQL server through socket ‘/Data/mydata/mysql.sock’ socket文件目录不对应导致的问题 4、今天要说的就是 没有打开only_full_group_by Cause:...
An ISP earns its money by charging each of the the ISPs that connect to the IXP a relatively small fee, which may depend on the amount of traffic sent to or received from the IXP. 15. Google's ...
使用Navicat远程服务器mysql数据库时报错误:2013-Lost connection to MYSQL server at ‘waitting for initial communication packet’,system error:0 操作流程一、检验Mysql数据库是否安装成功二、对Mysql的配置...
### MySQL 5.7 中 max_allowed_packet 参数的理解与调整 #### 一、max_allowed_packet 参数简介 在MySQL数据库中,`max_allowed_packet` 参数用于控制客户端与服务器之间单个数据包的最大大小。此参数对诸如大BLOB...
Packet Tracer DSL.Modem 连接实验 Packet Tracer DSL.Modem 连接实验是使用 Packet Tracer 软件模拟远程拨号通信,连接两台远程主机,使其能互相通信的实验。实验中使用了 DSL.Modem 和云图,连接网络,模拟远程...