The disconnection of the database connection pool, the failure recovery function is very important, do not know the current mainstream database connection pool: C3p0,proxool,bonecp,druid and so on support.
I know:
proxool: ?
1 2 3 4 5 6 7 8 9 10 |
<!--proxool resolves a problem with a database disconnect (Housekeepingtestsql is Oracle syntax, other databases are similar)--> < property name = "Housekeepingtestsql" > < value >select 1 dual</value > </Property > < property name = "Testbeforeuse" > < Value >true</value > </Property > < property name = "Testafteruse" > < value >true</VA Lue > </Property > |
c3p0:
breakafteracquirefailure:false
True indicates that pool is marked as block and close after a failed connection to the database, and that the client's request for pool is rejected even if the back-end database resumes normal and does not reconnect. False indicates that pool is not marked as block, and the new request attempts to connection the database request. The default is False. Therefore, if you want the database and network to recover, pool can continue to request normal resources must set this configuration to false
testconnectiononcheckout:false
true means to test its validity every time a connection is checkout from the pool, this is a synchronous operation, so every database call on the application side tests its validity through test SQL, if the connection is not valid , the connection is closed and the pool is removed and an attempt is made to fetch another connection from the pool, which defaults to false, which is used with caution and can cause at least one more database call. &NBSP
testconnectiononcheckin:false
True means that each time the connection is checkin into the pool, the validity is tested because it is an afterthought, so it is asynchronous, and the application does not have to wait for the test results, but it can also cause at least one more times of database calls. &NBSP
idleconnectiontestperiod:60
&NBSP;C3P0 There will be a task to detect if the connection within the pool is normal. This parameter is the frequency at which the task runs. The default value is 0, which means no detection. &NBSP
acquireretryattempts:10
retry times
acquireretrydelay:1000
Retry time interval
Feel disconnected automatic re-linked function performance, do not know if there is no better way to achieve.