Use of database connection pooling DBCP and C3P0

Source: Internet
Author: User
Tags connection pooling mysql in

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.