Communications link failure due to: java.io.EOFException

前端 未结 1 1850
你的背包
你的背包 2020-12-10 20:50

My webapp is running on Tomcat 5.5, I declared the datasource in web.xml:


    jdbc/OrdiniWebDS
         


        
相关标签:
1条回答
  • 2020-12-10 20:55

    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

    0 讨论(0)
提交回复
热议问题