WebApp (Tomcat-jdbc) Pooled DB Connection throwing Abandon 异常
我已经浏览了SO一段时间,并在此过程中咀嚼我的帽子,但找不到与我的问题完全匹配的。
简而言之,在60秒不活动后,我得到了极好的堆栈跟踪(org.apache.tomcat.jdbc.pool.ConnectionPool abandon),这是几个服务器端线程的正常行为。
我正在使用Tomcat JDBC Connection Pooling(org.apache.tomcat.jdbc.pool.DataSource)直接
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)
我的池属性配置如下:
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);
我希望setValidationInterval(30000)能拯救我,因为30s在连接生命周期中并不多。无论如何,问题是:
我错过了什么来保持这种联系永远活着?
很高兴知道 :为什么我在声明连接的函数中超时,尽管它在30秒前被调用。