常用数据库连接池 (DBCP、c3p0、Druid) 配置说明 (7)

:如果开启"removeAbandoned",那么连接在被认为泄露时可能被池回收. 这个机制在(getNumIdle() < 2)and (getNumActive() > getMaxActive() - 3)时被触发. 举例当maxActive=20, 活动连接为18,空闲连接为1时可以触发"removeAbandoned".但是活动连接只有在没有被使用的时间超过"removeAbandonedTimeout"时才被删除,默认300.resultset中游历不被计算为被使用.

 

If you have enabled removeAbandonedOnMaintenance or removeAbandonedOnBorrow then it is possible that a connection is reclaimed by the pool because it is considered to be abandoned. This mechanism is triggered when (getNumIdle() < 2) and (getNumActive() > getMaxTotal() - 3) and removeAbandonedOnBorrow is true; or after eviction finishes and removeAbandonedOnMaintenance is true. For example, maxTotal=20 and 18 active connections and 1 idle connection would trigger removeAbandonedOnBorrow, but only the active connections that aren\'t used for more then "removeAbandonedTimeout" seconds are removed (default 300 sec). Traversing a resultset doesn\'t count as being used. Creating a Statement, PreparedStatement or CallableStatement or using one of these to execute a query (using one of the execute methods) resets the lastUsed property of the parent connection.

 
4.2 C3P0  属性说明表

属性(Parameter)

 

默认值(Default)

 

描述(Description)

 

user

 

 

 

DBCP中的username属性

 

password  

 

 

 

DBCP中的password属性

 

jdbcUrl

 

 

 

DBCP中的jdbcUrl属性

 

driverClass

 

 

 

DBCP中的driverClass属性

 

autoCommitOnClose

 

false

 

默认值false表示回滚任何未提交的任务,设置为true则全部提交,而不是在关闭连接之前回滚

(C3P0\'s default policy is to rollback any uncommitted, pending work. Setting autoCommitOnClose to true causes uncommitted pending work to be committed, rather than rolled back on Connection close.)

*参见DBCP中的defaultAutoCommit属性

 

initialPoolSize

 

3

 

初始化连接:连接池启动时创建的初始化连接数量(The initial number of connections that are created when the pool is started.

*参见DBCP中的initialSize属性

 

maxPoolSize

 

15

 

连接池中保留的最大连接数(Maximum number of Connections a pool will maintain at any given time.)      *参见DBCP中的maxIdle属性

 

minPoolSize

 

3

 

连接池中保留的最小连接数(Minimum number of Connections a pool will maintain at any given time.)      *参见DBCP中的maxIdle属性

 

maxIdleTime

 

0

 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzyfyz.html