出现异常”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. make cmake catkin_make

    在Linux下进行C语言编程,必然要采用GNU GCC来编译C源代码生成可执行程序. 一.GCC快速入门 Gcc指令的一般格式为:Gcc [选项] 要编译的文件 [选项] [目标文件] 其中,目标文件 ...

  2. JavaScript判断对象 是什么类型的.

    // 这种方法不起作用 if (x == undefined) {   // 作某些操作 } // 这个方法同样不起作用- if (typeof(x) == undefined) {   // 作某些 ...

  3. 利用基准电压效正Vcc做参考电压的ADC采样计算方法

    利用基准电压效正Vcc做参考电压的ADC采样计算方法

  4. python中定制类

    1.python中__str__和repr 如果要把一个类的实例变成 str,就需要实现特殊方法__str__(): class Person(object): def __init__(self, ...

  5. samba 4.7.16 安装配置详解

    系统:Centos 7.4 x64位 服务版本:samba-4.7.1.samba-client-4.7 Samba 简介 Samba 是在Linux和UNIX系统上实现SMB协议的一个免费软件,由服 ...

  6. windows10下Python如何设置环境变量

    1.右击“我的电脑”,选择“属性”, 2.选择“高级系统设置”, 3.选择“环境变量”, 4.在“系统变量”中选中“Path”,再点“新建”.(Python.Scripts两个目录都要加,只加Pyth ...

  7. 使用display:table使两栏布局高度相等

    两栏布局大家应该经常用了,但是遇到坑爹的要两栏的高度对齐的话要怎么办呢? <!DOCTYPE html> <html> <head> <meta charse ...

  8. Linux 设备驱动之 UIO 机制

    一个设备驱动的主要任务有两个: 1. 存取设备的内存 2. 处理设备产生的中断 对于第一个任务.UIO 核心实现了mmap()能够处理物理内存(physical memory),逻辑内存(logica ...

  9. 使用TypeScript拓展你自己的VSCode

    转自:http://www.iplaysoft.com/brackets.html使用TypeScript拓展你自己的VSCode! 0x00 前言在前几天的美国纽约,微软举行了Connect(); ...

  10. DP问题如何确定状态

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