今天在使用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. C++面试集锦( 面试被问到的问题 )

    1. C 和 C++ 区别 2. const 有什么用途     主要有三点: 1:定义只读变量,即常量 2:修饰函数的参数和函数的返回值 3: 修饰函数的定义体,这里的函数为类的成员函数,被cons ...

  2. ATS 自定义日志格式

    字段解释 %<chi> 客户端IP %<caun> The username of the authenticated client. A hyphen (-) means t ...

  3. Eclipse中将web项目自动发布到Tomcat webapps下(转)

    A:FileàDynamic Web Project[工程名:test] B:右键WebContent,New-->Jsp File C:右键test,Run AsàRun on Serverà ...

  4. Java——java错误(The Struts dispatcher cannot be found)

    这通常是由于使用了struts标签,而没有配置相关联的filter.struts标签只有在http请求通过标签的servlet filter过滤器之后才可用,这些过滤器用来为这些标签初始化struts ...

  5. C# print2flash3文件转化

    1.下载print2flash3 并且安装print2flash3 2.转换工具类 (1)需要导入using Print2Flash3; 这个程序集 using System; using Syste ...

  6. react框架实现点击事件计数小案例

    下面将以一个小案例来讲解react的框架的一般应用,重点内容在代码段都有详细的解释,希望对大家有帮助 代码块: 代码块: import React from 'react'; import React ...

  7. mongodb系列~mongo常用命令

    mongodb常用命令大全1 索引相关命令 db.chenfeng.ensureIndex({"riqi":1}) 添加索引会阻塞nohup mongo --eval " ...

  8. case7 淋巴瘤子类分类实验记录

    case7 淋巴瘤子类分类实验记录 简介 分类问题:3分类 (identifying three sub-types of lymphoma: Chronic Lymphocytic Leukemia ...

  9. Android性能优化系列之Bitmap图片优化

    https://blog.csdn.net/u012124438/article/details/66087785 在Android开发过程中,Bitmap往往会给开发者带来一些困扰,因为对Bitma ...

  10. ubuntu14.04 安装Kdevelop 进行ROS开发

    1. 安装gcc sudo apt-get build-dep gcc sudo apt-get install build-essential  2. 安装Kdevelop sudo apt-get ...