The Hibernate Development Group recommends the use of c3p0;
The Spring Development Group recommends the use of DBCP;
hibernate in action recommends using C3P0;
DBCP in the database server cannot reconnect
After you forcibly close the connection or the database service restarts
two. DBCP connection pool is created faster than C3P0, and c3p0 performance is more stable
three. The Mysql8 hour problem is resolved differently:
well known, MySQL in the process of use, a connection in 8 hours without any action, the connection will be disconnected, The connection in the connection pool is not aware of the disconnection operation. DBCP and C3P0 give different solutions:
DBCP need to add two configuration parameters:
<set-property property= "Testonborrow" value= "true"/> <set-property property= "validationquery" value= " Select 1 "/>
Testonborrow means that when a connection is made from a database connection pool, its validity is checked
Validationquery is the SQL statement used to check, "SELECT 1" Executes faster and is a good detection statement
C3P0 need to add a parameter:
<property name= "MaxIdleTime" value= "1800"/>
MaxIdleTime is the lifetime of the connection in the connection pool, which is less than the Wait_timeout value set on the MySQL server
Use of database connection pooling DBCP and C3P0