The last packet successfully received from the server was milliseconds ago

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 8,964,867 milliseconds  
 ago.  The last packet sent successfully to the server was 8,964,867 millisecond
s ago.

这个问题把 timeout  idle_test_period 设置好了应该就可以了,不能超过mysql默认的8小时,参考如下:

、C3P0数据库连接池属性:
         1)hibernate.c3p0.max_size:最大连接数
          2)hibernate.c3p0.min_size:最小连接数
          3)hibernate.c3p0.acquire_increment:当数据库连接池中的连接耗尽时,同一时刻获取多少个数据库连接
 
          4)hibernate.c3p0.timeout:连接池中连接对象在多长时间没有使用过后,就应该被销毁
          5)hibernate.c3p0.idle_test_period:表示连接池检测线程多长时间检测一次池内的所有连接对象是否超时,连接池本身不会把自己从连接池中移除
而是专门有一个线程按照一定的时间间隔来做这件事,这个线程通过比较连接对象最后一次呗使用和当前时间的时间差来和timout做对比,进而决定是否销
毁这个连接对象。
          6)hibernate.c3p0.max_statements:缓存Statement对象的数量
          
          
       <property name="hibernate.c3p0.max_size">10</property>
       <property name="hibernate.c3p0.min_size">5</property>
       <property name="hibernate.c3p0.acquire_increment">2</property>
       <property name="hibernate.c3p0.timeout">2000</property>
       <property name="hibernate.c3p0.idle_test_period">2000</property>
       <property name="hibernate.c3p0.max_statements">10</property>

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值