出现异常”The last packet sent successfully to the server was 0 milliseconds ago.“的大部分原因是由于数据库回收了连接,而系统的缓冲池不知道,继续使用被回收的连接所致的。

以mysql为例:

第一种解决办法,就是将mysql回收空闲连接的时间变长,mysql默认回收时间是8小时,可以在mysql目录下的my.ini中增加下面配置,将时间改为1天。

单位是秒,最大好像是24天:

[mysqld]

wait_timeout=86400

第二种解决办法,可以通过配置,让缓冲池去测试连接是否被回收,如果被回收,则不继续使用,以dbcp为例:

#SQL查询,用来验证从连接池取出的连接           dbcp.validationQuery=SELECT 1           #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除           dbcp.testWhileIdle=true           #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小           dbcp.timeBetweenEvictionRunsMillis=300000           #在每次空闲连接回收器线程(如果有)运行时检查的连接数量,最好和maxActive一致          dbcp.numTestsPerEvictionRun=50           #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位           dbcp.minEvictableIdleTimeMillis=3600000

The last packet sent successfully to the server was 0 milliseconds ago的更多相关文章

  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 sent successfully to the server was 0 milliseconds ago.[nutch---mysql ]

    今天在使用JDBC操作mysql时遇到下面的异常信息: 引用 The last packet sent successfully to the server was 0 milliseconds ag ...

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

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

  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. 【hihocoder】三十九周:二分.归并排序之逆序对

    就是用归并排序求数组中得逆序对.假设数组为a:[2 4 5],和b:[1 3],那么在这一次归并的时候逆序对这样求,belement表示当前result数组中b数组对应的元素个数,total表示逆序对 ...

  2. Python3:文件读写

    Python3:文件读写 open f = open('filename','r') # 读模式 f = open('filename','w') # 写模式 f = open('filename', ...

  3. mfc报文相关算法

    1.传入_T("AAAABBBBCC"),返回_T("AA AA BB BB CC") CString FormatPacket(CString packet_ ...

  4. JUnit4 入门笔记

    Test注解的两个可选参数 expected timeout The Test annotation supports two optional parameters. The first, expe ...

  5. v4l2中的多流机制

    一直在搞camera,对v4l2也比较熟悉了,今天写文章说点自己的看法 对于v4l2,对多流的支持是比较弱的,只是一个流.但现在的camera 硬件,能支持多个流同事工作,所以又必要对v4l2的api ...

  6. 微信小程序选择器

  7. RabbitMQ 之 WorkQueues工作队列

    模型图 为什么会出现 work queues? 前提:使用 simple 队列的时候 (上一篇博客)我们应用程序在是使用消息系统的时候,一般生产者 P 生产消息是毫不费力的(发送消息即可),而消费者接 ...

  8. 十二道MR习题 - 2 - 多文件保存

    题目: 需要将MR的执行结果保存到3个文件中,该怎么做. 又是一个送分题. 对于Hadoop的MapReduce来说只需要设置一下reduce任务的数量即可.MR的Job默认reduce数量是1,需要 ...

  9. DP问题如何确定状态

    DP问题如何确定状态 一.dp实质 动态规划的实质就是通过小规模的同类型的问题来解决题目的问题. 所以有一个dp数组来储存所有小规模问题的解. 所以确定状态也就是缩小问题规模. 我们求解问题的一般规律 ...

  10. python学习笔记(unittest)

    刚刚放假回来我想很多人都还没有缓过来吧 这次介绍一个python自带的测试框架 unitest #!/usr/bin/env python # -*- coding: utf_8 -*- import ...