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

获取连接失败将会引起所有等待连接池来获取连接的线程抛出异常。但是数据源仍有效保留,并在下次调用 getConnection() 的时候继续尝试获取连接。如果为 true,那么在尝试获取连接失败后该数据源将声明已断开并永久关闭。(If true, a pooled DataSource will declare itself broken and be permanently closed if a Connection cannot be obtained from the database after making acquireRetryAttempts to acquire one. If false, failure to obtain a Connection will cause all Threads waiting for the pool to acquire a Connection to throw an Exception, but the DataSource will remain valid, and will attempt to acquire again following a call to getConnection().)

 

checkoutTimeout

 

0

 

当连接池用完时客户端调用 getConnection() 后等待获取新连接的时间,潮湿后将抛出SQLException,如设为0,则为无限期等待。单位毫秒。(The number of milliseconds a client calling getConnection() will wait for a Connection to be checked-in or acquired when the pool is exhausted. Zero means wait indefinitely. Setting any positive value will cause the getConnection() call to time-out and break with an SQLException after the specified number of milliseconds.)

 

maxStatements

 

0

 

控制数据源内加载的PreparedStatements数量(Enable prepared statement pooling for this pool.)

 

maxStatementsPer- Connection

 

0

 

定义了连接池内单个连接所拥有的最大缓存statements(The maximum number of open statements that can be allocated from the statement pool at the same time, or negative for no limit.)

 
4.3 DRUID 属性说明表

属性(Parameter)

 

默认值(Default)

 

描述(Description)

 

username

 

 

 

连接数据库的用户名

 

password  

 

 

 

连接数据库的密码

 

jdbcUrl

 

 

 

DBCP中的jdbcUrl属性

 

driverClassName

 

根据url自动识别

 

这一项可配可不配,如果不配置druid会根据url自动识别dbType,然后选择相应的driverClassName

 

initialSize

 

0

 

初始化时建立物理连接的个数。初始化发生在显示调用init方法,或者第一次getConnection                   *参见DBCP中的initialSize属性

 

maxActive

 

8

 

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

 

maxIdle

 

8

 

已经不再使用,配置了也没效果                        *参见DBCP中的maxIdle属性

 

minIdle

 

 

 

最小连接池数量

 

maxWait

 

 

 

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

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