今天在使用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. JAVA-常用集合类型转换例子(基础必备)

    package com.net.xinfang.reflect; import java.util.ArrayList; import java.util.Arrays; import java.ut ...

  2. WinForm ListView虚拟模式加载数据 提高加载速度

    将VirtualMode 属性设置为 true 会将 ListView 置于虚拟模式.控件不再使用Collection.Add()这种方式来添加数据,取而代之的是使用RetrieveVirtualIt ...

  3. Html-Css 从入门到放弃(一)基础知识

    注意要点: 1.ID属性不要以数字开头,数字开头的ID在 Mozilla/Firefox 浏览器中不起作用. 2.class 选择器用于描述一组元素的样式,class 选择器有别于id选择器,clas ...

  4. Linux - 操作系统信号

    linux操作系统提供的信号 kill -l # 查看linux提供的信号 trap # shell使用 trap 捕捉退出信号 # 发送信号一般有两种原因: # (被动式) 内核检测到一个系统事件. ...

  5. 列表视图QlistView

    列表视图QlistView要配合setModel模型一起使用 例子一 QStringListModel()  字符串列表模型 import sys from PyQt5.QtWidgets impor ...

  6. jdk学习之如何调试jdk

    自从sun被oracle收购后,在oracle下载的jdk使用F5进入调试jdk的方法就不行了,这对于想看jdk的源码的小伙伴是一个暴击(oracle在编译rt.jar时去除了调试信息): 这不得不鼻 ...

  7. R 的农场 chebnear (二分答案+最近平面点对)

    题面 \(solution:\) 这道题想到二分答案应该是不难的,因为题目是求平均工资的最小值,这个显然具备单调性: 我们设平均工资的最小值为ans,如果我们现在的平均工资x小于ans那么将x带入题目 ...

  8. MySQL备份可能遇到的坑

    MySQL备份工具,支持各种参数选项,使用不同的选项极有可能影响备份处理过程.本文使用我们常规认为合理的备份参数,测试/验证是否存在容易忽视的坑 # 常规备份参数 # mysqldump shell& ...

  9. mysql 原理~ index的详解

    一 简介:今天咱们来介绍下index的一些东西 二 数据的基本存储结构 1 磁盘空间被划分为许多大小相同的块(Block) 在内存中读出是页(Page).   2 一个表的这些数据块以链表的方式串联在 ...

  10. ubuntu14.04 提示 卷 文件系统根目录 仅剩余xxx的硬盘空间