首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

The last packet sent successfully to the server was 零 milliseconds ago

2013-09-11 
The last packet sent successfully to the server was 0 milliseconds ago.今天在使用JDBC操作mysql时遇

The last packet sent successfully to the server was 0 milliseconds ago.
今天在使用JDBC操作mysql时遇到下面的异常信息:
配置:ubuntu10.105.1.49-1ubuntu8.1mysql-connector-java-5.1.18.jar

交互:
300k records
300k * 10 = 3M次访问mysql
处理时间0.5h以内

解决方法:
(1)使用JDBC URL中使用autoReconnect属性,url添加

&autoReconnect=true&failOverReadOnly=false&maxReconnects=10

(2) 修改MySQL的参数. /etc/my.cnf 添加
[mysqld]wait_timeout=31536000interactive_timeout=31536000

(3)重启mysql
service mysql restart


原因分析:
(1)大量数据访问情况下,mysql connection连接有可能失效
(2)长时间不妨问,connection会失效

更多参考:
http://dev.mysql.com/doc/refman/5.1/zh/database-administration.html#dynamic-system-variables
http://www.blogjava.net/heweiya/archive/2006/01/18/28483.html
1 楼 hhsc00 2012-05-15   连接字符串URL中,将localhost改成127.0.0.1,就OK了。

原因见:
Testing your connectivity with the mysql command-line client will not work unless you add the –host flag, and use something other than localhost for the host. The mysql command-line client will use Unix domain sockets if you use the special host name localhost. If you are testing connectivity to localhost, use 127.0.0.1 as the host name instead.

引用自:http://dev.mysql.com/doc/refman/5.0/en/connector-j-usagenotes-troubleshooting.html
我的异常网推荐解决方案:The driver has not received any packets from the server.,http://www.myexception.cn/j2ee/345243.html

热点排行