I have been browsing SO for some time, and chewing my hat in the process, but cannot find an exact match to my problem.
For short, I am getting superb stack trace (org.apache.tomcat.jdbc.pool.ConnectionPool abandon) after 60 seconds of inactivity, which is a normal behavior for a couple of server side threads.
I am using Tomcat JDBC Connection Pooling (org.apache.tomcat.jdbc.pool.DataSource) directly
Stack Trace:
Oct 29, 2012 8:55:50 PM org.apache.tomcat.jdbc.pool.ConnectionPool abandon WARNING: Connection has been abandoned PooledConnection[com.mysql.jdbc.JDBC4Connection@1ad2916]:java.lang.Exception at org.apache.tomcat.jdbc.pool.ConnectionPool.getThreadDump(ConnectionPool.java:967) at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:721) at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:579) at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:174) at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:111) at com.getsom.getConnection(DAO.java:1444) at com.getsom.PreparedConnection.(PreparedConnection.java:48) at com.getsom.Alarms.run(Alarms.java:492)
My PoolProperties are configured as follows:
PoolProperties pp = new PoolProperties();
pp.setUrl( someValidUrl);
pp.setDriverClassName("com.mysql.jdbc.Driver");
pp.setUsername( someUser);
pp.setPassword( somePassword);
pp.setJmxEnabled( true);
pp.setTestWhileIdle( true);
pp.setTestOnBorrow( true);
pp.setValidationQuery( "SELECT 1");
pp.setTestOnReturn( false);
pp.setValidationInterval(30000);
pp.setTimeBetweenEvictionRunsMillis(30000);
pp.setMaxActive(100);
pp.setInitialSize(10);
pp.setMaxWait(10000);
pp.setMinEvictableIdleTimeMillis(30000);
pp.setMinIdle(10);
pp.setLogAbandoned(true);
pp.setRemoveAbandoned(true);
pp.setRemoveAbandonedTimeout(60);
pp.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"+
"org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
setPoolProperties(pp);
I was hoping setValidationInterval(30000) would save me, since 30s is not much in a connection life cycle. Anyway the question is:
What am I missing to keep this connection alive forever?
A nice to know : Why am I timing out in the function that claimed the connection, although it was invoked 30 seconds earlier.