DBCP连接属性

时间:2012-05-03 22:50:10

标签: java connection-pooling apache-commons-dbcp

我们很难找出属性definedminIdlemaxIdle等。

我们在以下设置中看到以下错误

InitialSize=5
maxActive=50
maxIdle=40
maxWait=2000
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idle object
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:1001)
    at org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1064)

    ... 36 more
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idle object
    at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:114)
    at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
    at org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource.getConnection(AbstractRoutingDataSource.java:148)
    at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
    ... 39 more
Caused by: java.util.NoSuchElementException: Timeout waiting for idle object
    at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1134)
    at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:106)

1 个答案:

答案 0 :(得分:0)

这已经解决了。问题是来自错误的应用程序代码的连接泄漏。编写应用程序代码是为了访问底层本机连接以使用Oracle阵列类型而不是正确管理。将代码更改为使用SimpleNativeJdbcExtractor

http://static.springsource.org/spring/docs/2.0.x/api/org/springframework/jdbc/support/nativejdbc/SimpleNativeJdbcExtractor.html