Communications link failure due to: java.io.EOFException

旧时模样 提交于 2019-11-28 11:43:54
Aaron Digulla

MySQL drops unused connections after a while because it assumes that the other side forgot to close it.

What you need to do is to configure a check that Tomcat should apply before it reuses a pooled connection. To do this, add ?autoReconnect=true&useUnicode=true&characterEncoding=utf8 to the end of the URL and add validationQuery="Select 1" to the Resource element:

<Resource 
  auth="Container" 
  driverClassName="com.mysql.jdbc.Driver" 
  maxActive="100" 
  maxIdle="30" 
  maxWait="10000" 
  name="jdbc/OrdiniWebDS" 
  password="[mypassword]" 
  type="javax.sql.DataSource" 
  url="jdbc:mysql://[myHost:port]/ordiniweb?autoReconnect=true&useUnicode=true&characterEncoding=utf8" 
  username="[myusername]"
  validationQuery="Select 1"
 />

[EDIT] This page gives more details: Configuring a MySQL Datasource in Apache Tomcat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!