今天在使用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泛型中的类型擦除及为什么不支持泛型数组

    一,数组的协变性(covariant array type)及集合的非协变性 设有Circle类和Square类继承自Shape类. 关于数组的协变性,看代码: public static doubl ...

  2. 异常处理com.sun.image.codec.jpeg.JPEGImageEncoder

    以下方案不一定能解决问题.解决方案:配置JDK的JRE_HOME 环境变量既可. Linux 下配置  : vi /etc/profile 在profile文件下面追加写入下面信息: export J ...

  3. Mybatis中的StatementType

    原文:http://luoyu-ds.iteye.com/blog/1517607 要实现动态传入表名.列名,需要做如下修改 添加属性statementType=”STATEMENT” 同时sql里的 ...

  4. Linux 4.10.8 根文件系统制作(一)---环境搭建

    一.工具 制作工具为busybox 下载地址:https://busybox.net/ 解压: 二.制作文件系统 进入目录,执行make menuconfig: 2.1 busybox setting ...

  5. E - tower HYSBZ - 4657 (网络流割点)

    题目链接:https://cn.vjudge.net/contest/281959#problem/E 题目大意:中文题目 具体思路:首先,有矛盾的时候就是两个导弹的运动轨迹会相交的时候,那么我们可以 ...

  6. B - Frogger 最短路变形('最长路'求'最短路','最短路'求'最长路')

    http://poj.org/problem?id=2253 题目大意: 有一只可怜没人爱的小青蛙,打算去找他的女神青蛙姐姐,但是池塘水路不能走,所以只能通过蹦跶的形式到达目的地,问你从小青蛙到青蛙姐 ...

  7. TIdHTTP get参数带中文解决方法--请求报文

    Post 看起来稍微复杂先,暂不讨论.post 目前按照一般方法有中文名也可以. 拼接时:pointname=九记餐厅&begintime=2017-03-01 00:00:00& 有 ...

  8. Responsive响应式设计

    在IE6-8中完全是不支持CSS3 Media Queries的.那么为了让IE6-8支持,我们就很有必要的在IE9以下的浏览器中加上media-queries.js或者respond.js脚本: & ...

  9. session和cookies

    Cookie 与session的产生过程                                 我们都知道HTTP协议本身是无状态的,客户只需要简单的向服务器来发送请求下载某些文件,客户端向 ...

  10. Android BroadcastReceiver 面试解析