1

Recently we had to restart our database server (yes, a production one), and one of the Tomcats didn't reconnect to the JNDI resources.

This is our JNDI resource definition:

<Resource name="jdbc/postgres" auth="Container"
          type="javax.sql.DataSource"
          driverClassName="org.postgresql.Driver"
          url="jdbc:postgresql://10.1.0.104:5432/db"
          username="******" password="*****"
          maxTotal="30" maxIdle="5" maxWaitMillis="10000"
          logAbandoned="true" removeAbandonedOnBorrow="true"
          removeAbandonedOnMaintenance="true"
          factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
          validationQueryTimeout="5" validationQuery="select 1"
          testOnBorrow="true" />

Software versions:

  • Debian GNU/Linux 8.2 (jessie)
  • Apache Tomcat/8.0.14
  • OpenJDK 1.7.0_91-b02
  • PostgreSQL 9.4.5 on x86_64-unknown-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit

What could be wrong? Why it didn't reconnect automatically?

PS: This maybe is a cross forum question dba vs stackoverflow, but as it involves both side don't know actually where to ask it.

1

1 Answer 1

1

It could happen on database server restart that the webserver connection pool become faulty or incapable of reconnect to the db. If you can't restart your Tomcat instance after the database restart (easiest choice) you should configure your connection pool to test, remove and replace your connections. See the validationQuery, testOnConnect and testWhileIdle attributes in the Tomcat 8 jdbc-pool guide.

Sign up to request clarification or add additional context in comments.

1 Comment

I already gave the validationQuery, but not the other 2 attributes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.