我有一个tomcat实例设置,但我配置的数据库连接context.xml在一段时间不活动后仍然会死.
当我检查日志时,我收到以下错误:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:从服务器成功收到的最后一个数据包是68051秒前.成功发送到服务器的最后一个数据包是68051秒前,这比服务器配置的'wait_timeout'值长.您应该考虑在应用程序中使用之前过期和/或测试连接有效性,增加服务器配置的客户端超时值,或使用Connector/J连接属性"autoReconnect = true"来避免此问题.
这是context.xml中的配置:
<Resource name="dataSourceName"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="username"
password="********"
removeAbandoned = "true"
logAbandoned = "true"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/databasename?autoReconnect=true&useEncoding=true&characterEncoding=UTF-8" />
Run Code Online (Sandbox Code Playgroud)
我正在使用autoReconnect=true错误说要做,但连接一直在死.我以前从未见过这种情况.
我还验证了所有数据库连接都已正确关闭.