日志输出The last packet successfully received问题以及c3p0解决方案,max_statements

今天部署项目上线 然后sql查询失败,看日志发现

The last packet successfully received from the server was 607,486 milliseconds ago. The last packet sent successfully to the server was 3,980,005 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

提示你修改参数什么的(不要用),这个方法很不好

修改MySQL的参数了,wait_timeout最大为31536000即1年,在my.cnf中加入:

[mysqld]

wait_timeout=31536000

interactive_timeout=31536000

重启生效,需要同时修改这两个参数。

然后我的连接池是c3p0,遇到这个问题的伙伴可以根据不同的数据连接池去找你们的相关配置。

c3p0修改解决这个问题:

1、数据库执行命令:

show global variables like '%timeout%';

查看你的数据库的wait_timeout时间

然后根据你的时间去设置<property name="idleConnectionTestPeriod"><value>3</value></property> 的值,如果是30 那value就小于30,10的话就小于10,必须是小于!

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"    destroy-method="close">
<property name="driverClass" value="${jdbc.driverClass}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.user}"/>
<property name="password" value="${jdbc.password}"/>
       <property name="minPoolSize"><value>1</value></property>
        <property name="maxPoolSize"><value>20</v
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值