Tracing Unclosed Database Connections in Tomcat DBCP

January 20, 2011

You can get Tomcat to output details of unclosed database connections, by configuring the data source using logAbandoned

Here's example config:

<Resource auth="Container" 
  name="jdbc/DataSourceName" 
  type="javax.sql.DataSource" 
  url="jdbc:hsqldb:hsql://localhost:9820/database" 
  password="" 
  maxActive="4" 
  maxWait="5000" 
  driverClassName="org.hsqldb.jdbcDriver" 
  username="sa" 
  maxIdle="2"
  removeAbandoned="true"
  removeAbandonedTimeout="60"
  logAbandoned="true" />

I didn't need to take this any further for the problem I was having - this information added here for future reference.