druid 是一个用于 Java 的高效数据库连接池,它提供了强大的监控和扩展功能。
空闲等待超时
Java
Caused by:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:The last packet successfully received from the server was 65,699,330 milliseconds ago. The last packet sent successfully to the server was 65,699,330 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)是28800,也就是8小时,而druid连接池参数max-wait是30000
连接空闲超时问题的原因通常与连接池和数据库服务器之间的配置不匹配有关。当连接池中的连接长时间处于空闲状态时,数据库服务器可能会关闭这些空闲连接以节省资源。这种情况下,连接池可能仍然认为这些连接是有效的,但实际上数据库服务器已经释放了它们。
以下是引发连接空闲超时问题的一些可能原因:
服务器端的 wait_timeout 设置较低:数据库服务器会在连接空闲一段时间后关闭它们。如果服务器的 wait_timeout 参数设置得较低,连接池中的空闲连接可能在被使用前就已被服务器关闭。
连接池配置不合理