ln12341234 2020-10-14 16:25 采纳率: 75%
浏览 1084
已采纳

mysql链接超时 is longer than the server configured value of 'wait_timeout'

1.问题描述

系统运行阶段出现报错 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 427,583,591 milliseconds ago. The last packet sent successfully to the server was 427,583,592 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.
实际上当前数据源配置文件已加上autoReconnect=true,
mysql wait_timeout 值为默认值8小时 28800
mysql版本:5.6.41
数据库链接池:tomcat jdbc

请问该如何解决。

2.相关配置

数据源配置文件:

<bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy-method="close">
            <property name="driverClassName" value="${jdbc.driver}" />
            <property name="url" value="jdbc:mysql://xxxx:3306/xxx?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false" />
            <property name="username" value="${jdbc.username}" />
            <property name="password" value="${jdbc.password}" />
            <property name="maxActive" value="100" />
            <property name="maxIdle" value="50" />
            <property name="minIdle" value="5" />
            <property name="maxWait" value="-1" />
            <property name="validationQuery" value="SELECT 1" />
            <property name="testWhileIdle" value="true" />
            <property name="timeBetweenEvictionRunsMillis" value="60000" />
            <property name="minEvictableIdleTimeMillis" value="60000" />
            <property name="defaultAutoCommit" value="false" />
        </bean>

mysql配置文件:

[mysqld]
innodb_buffer_pool_size = 150G
 join_buffer_size = 256M
 sort_buffer_size = 20M
 read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
group_concat_max_len = 1024000

symbolic-links=0

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
transaction-isolation=READ-COMMITTED

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

3.错误信息

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 427,583,591 milliseconds ago. The last packet sent successfully to the server was 427,583,592 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.

  • 写回答

1条回答 默认 最新

  • SpringBoot中文社区 2020-10-14 17:02
    关注

    好像mysql官方不建议 使用autoReconnect参数,你换个数据源试试看?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?