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

最大等待时间:当没有可用连接时,连接池等待连接被归还的最大时间(以秒计数),超过时间则抛出异常,如果设置为0表示无限等待(Seconds a Connection can remain pooled but unused before being discarded. Zero means idle connections never expire.)                            *参见DBCPmaxWaitMillis 属性

 

preferredTestQuery

 

null

 

定义所有连接测试都执行的测试语句。在使用连接测试的情况下这个一显著提高测试速度。注意:测试的表必须在初始数据源的时候就存在。(Defines the query that will be executed for all connection tests, if the default ConnectionTester (or some other implementation of QueryConnectionTester, or better yet FullQueryConnectionTester) is being used. Defining a preferredTestQuery that will execute quickly in your database may dramatically speed up Connection tests.)

 

testConnectionOn- Checkin

 

false

 

如果设为true那么在取得连接的同时将校验连接的有效性。(If true, an operation will be performed asynchronously at every connection checkin to verify that the connection is valid. Use in combination with idleConnectionTestPeriod for quite reliable, always asynchronous Connection testing.)                                     *参见DBCP中的testOnBorrow属性

 

testConnectionOn- Checkout

 

false

 

如果设为true那么在每个connection提交的时候都将校验其有效性,但是要确保配置的preferredTestQuery的有效性(If true, an operation will be performed at every connection checkout to verify that the connection is valid. Be sure to set an efficient preferredTestQuery or automaticTestTable if you set this to true.)                                 *参见DBCP中的testOnBorrow属性

 

idleConnectionTest- Period

 

0

 

如果设置大于0,表示过了多少秒检查一次空闲连接,结合testConnectionOnCheckin以及testConnectionOnCheckout使用(If this is a number greater than 0, c3p0 will test all idle, pooled but unchecked-out connections, every this number of seconds.)

 

acquireRetryAttempts

 

30

 

定义在从数据库获取新连接失败后重复尝试的次数, 如果小于0则表示无限制的连接。(Defines how many times c3p0 will try to acquire a new Connection from the database before giving up. If this value is less than or equal to zero, c3p0 will keep trying to fetch a Connection indefinitely.)

 

acquireRetryDelay

 

1000

 

两次连接中的间隔时间,单位毫秒。(Milliseconds, time c3p0 will wait between acquire attempts.)

 

breakAfterAcquire-

Failure

 

false

 

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

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