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

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参数,你换个数据源试试看?

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

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度