今天在使用JDBC操作mysql时遇到下面的异常信息:

引用
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. 
at com.tomymap.galaxy.virgo.util.DbService.getConnection(DbService.java:66) 
at com.tomymap.galaxy.virgo.util.DbService.getConnection(DbService.java:46) 
at com.tomymap.galaxy.virgo.dao.PNNDao.getConnection(PNNDao.java:51) 
at com.tomymap.galaxy.virgo.dao.DaoBase.executeUpdate(DaoBase.java:69) 
at com.tomymap.galaxy.virgo.dao.PNNDao.updatePNNRelation(PNNDao.java:161) 
at com.tomymap.galaxy.virgo.pnn.PyramidNeuralNetwork.buildPNNRelations(PyramidNeuralNetwork.java:400)
at com.tomymap.galaxy.virgo.pnn.PyramidNeuralNetwork.incrementalGenPNN(PyramidNeuralNetwork.java:144)
at com.tomymap.galaxy.virgo.pnn.PyramidNeuralNetwork.main(PyramidNeuralNetwork.java:410)

着实让人崩溃的信息,花费了一天的时间来解决。 
不罗嗦,直接描述解决办法。

  1. 配置:
  2. ubuntu10.10
  3. 5.1.49-1ubuntu8.1
  4. mysql-connector-java-5.1.18.jar

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

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

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

(2) 修改MySQL的参数. /etc/my.cnf 添加

  1. [mysqld]
  2. wait_timeout=31536000
  3. interactive_timeout=31536000

(3)重启mysql

  1. 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

The last packet sent successfully to the server was 0 milliseconds ago.[nutch---mysql ]的更多相关文章

  1. The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

    今天项目中报了如下错误 The last packet sent successfully to the server was 0 milliseconds ago. The driver has n ...

  2. The last packet successfully received from the server was 20,519 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago.

    本地升级了下MySQL的版本,从5.6升为5.7,数据文件直接拷贝的,项目查询数据库报错: Could not retrieve transation read-only status server ...

  3. Communications link failure;;The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

    Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure::The ...

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

    出现异常”The last packet sent successfully to the server was 0 milliseconds ago.“的大部分原因是由于数据库回收了连接,而系统的缓 ...

  5. docker 踩坑日记The last packet sent successfully to the server was 0 milliseconds ago.

    The last packet sent successfully to the server was 0 milliseconds ago. 今日遇到了这个坑,看似平白无奇. 首先,我定位到是数据库 ...

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

    出现异常"The last packet sent successfully to the server was 0 milliseconds ago."的大部分原因是由于数据库回 ...

  7. The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. (关于jdbc)

    The last packet sent successfully to the server was milliseconds ago. The driver has not received an ...

  8. 【异常】The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

    1 详细异常信息 The last packet sent successfully to the server was milliseconds ago. The driver has not re ...

  9. 【错误】:Could not open JDBC Connection for transaction; nested exception is: Communications link failure;The last packet sent successfully to the server was 1 milliseconds ago

    # #错误日志 2016-11-10 16:19:20,834 ERROR [org.quartz.core.JobRunShell] - Job DEFAULT.jobtask threw an u ...

随机推荐

  1. 为什么要用redis

    服务端的程序如何去识别客户端的状态: http是没有状态的,比如说用户A访问了服务器程序,那服务器如何知道下一次访问的时候还是A呢,这里就要用到session, 这个session是服务器的sessi ...

  2. Math.random()和UUID.randomUUID().toString()性能对比【纯原】

    Math.random()和UUID.randomUUID().toString()性能对比 不言而喻,因为Math.random()不需要保证唯一性,所做的操作远比UUID消耗更小的性能, 在部分要 ...

  3. Java编程思想 学习笔记9

    九.接口 接口和内部类为我们提供了一种将接口与实现分离的更加结构化的方法. 1.抽象类和抽象方法  抽象类是普通的类与接口之间的一种中庸之道.创建抽象类是希望通过这个通用接口操纵一系列类. Java提 ...

  4. I2C和SPI总线对比

    1 iic总线不是全双工,2根线SCL SDA.spi总线实现全双工,4根线SCK CS MOSI MISO 2 iic总线是多主机总线,通过SDA上的地址信息来锁定从设备.spi总线只有一个主设备, ...

  5. 三、编译第一步 make xxx_defconfig——Makefile.build 脚本

    3.1 上章分析回顾 3.1 上章分析出的参数 3.1.1 变量 MAKECMDGOALS = xxx_defconfig KBUILD_EXTMOD = version_h := include/g ...

  6. Postfix 邮件服务 - postfix服务

    postfix 邮件服务 也是基于sendmail (需要关闭或卸载sendmail)postfix 是一个电子邮件服务器,它为了改良sendmail邮件服务器而产生的,并且它的配置文件比sendma ...

  7. CF28D Don't fear, DravDe is kind

    传送门 题意:\(n\)个位置,每个位置有价值\(v_i\)和重量\(p_i\),要选出一些位置,如果要选位置\(i\),那么前面选的重量之和要为\(l_i\),后面选的重量之和要为\(r_i\),求 ...

  8. WPF GridView的列宽度设置为按比例分配

    <Grid> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="3*" / ...

  9. http raw post 之理解

    参考链接: https://imququ.com/post/four-ways-to-post-data-in-http.html http://blog.csdn.net/leyangjun/art ...

  10. Linux常用命令(一)查看日志

    当日志文件存储很大时,需要Linux命令查看: Log 在目录 /var/log/   下 常用命令: tail head grep sed cat tac https://blog.csdn.net ...