数据库连接超时(Tomcat 上的连接池)
我的 dB 连接经常超时。我查看了人们为此提供的一些解决方案,并实施了它们,但到目前为止还没有任何结果。任何新的想法都会非常有帮助。
问题
对于对 web 应用程序的某些请求,这是我收到的错误:
com.mysql.jdbc.CommunicationsException:最后一个数据包成功 从服务器收到的时间是 11,198,881 毫秒前。最后一个 数据包成功发送到服务器为 11,198,881 毫秒 前。比服务器配置的“wait_timeout”值长。你 应考虑过期和/或测试连接有效性 在您的应用程序中使用之前,增加服务器配置 客户端超时值,或使用 Connector/J 连接 属性“autoReconnect=true”以避免此问题。
尝试的解决方案
- 测试连接有效性
- 使用 autoReconnect
context.xml 的内容
资源名称=“jdbc/dBConnectionMain”auth=“容器” 类型=“javax.sql.DataSource”maxActive=“20”maxIdle=“18” removeAbandoned =“真”removeAbandonedTimeout =“60”logAbandoned =“真” validationQuery=“选择 1” testOnBorrow=“true” 用户名=“用户” 密码=“密码”driverClassName=“com.mysql.jdbc.Driver” url="jdbc:mysql://localhost/databaseName?autoReconnect=true" /
有任何指示吗?
干杯,
研发
My dB connections are constantly timing out. I looked through some of the solutions people have offered to this, and have implemented them, but nothing has worked out till now. Any new thoughts, will be very helpful.
Problem
For some requests to the webapp, this is the error I am getting :
com.mysql.jdbc.CommunicationsException: The last packet successfully
received from the server was 11,198,881 milliseconds ago. The last
packet sent successfully to the server was 11,198,881 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.
Solutions Tried
- Testing connection validity
- Using autoReconnect
Contents of context.xml
Resource name="jdbc/dBConnectionMain" auth="Container"
type="javax.sql.DataSource" maxActive="20" maxIdle="18"
removeAbandoned="true" removeAbandonedTimeout="60" logAbandoned="true"
validationQuery="select 1" testOnBorrow="true" username="user"
password="password" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/databaseName?autoReconnect=true" /
Any pointers on this?
Cheers,
RD
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论