Search code examples
springtomcatoracle11gconnection-poolinghibernate-entitymanager

tomcat connection interrupted after a period of inactivity


I am developing an application with spring and hibernate entityManager

The oracle database is outside the DMZ.

the connection will be interrupted after a period of inactivity by the firewall.

I added the ValidationQuery select 1 from dual in context.xml but it does not solve the problem.


Solution

  • In your datasource try to add the below. testWhileIdle

    <Resource auth="Container"
          type="javax.sql.DataSource"
          name="jdbc/testt"
          driverClassName="com.mysql.jdbc.Driver"
          url="jdbc:mysql://********/mydb"
          maxActive="10"
          maxIdle="5"
          validationQuery="SELECT 1"
          testOnBorrow="true"
          testWhileIdle="true"
          timeBetweenEvictionRunsMillis="10000"
          minEvictableIdleTimeMillis="60000"
          username="..." password="..."/>