[Java EE] Understanding Java connection pooling

Source: Internet
Author: User

Reprinted from 51CTO http://developer.51cto.com/art/201006/207768.htm

51CTO once introduced a simple Java connection pool for us. To understand Java connection pooling let's first understand the principle of database connection pooling (connection pool), where Java connection pooling is the application of database connection pooling in Java. --we know that there is a well-known design pattern for shared resources: resource pools (Resource pool). This model is to solve the problem caused by the frequent allocation of resources ﹑ release. To solve the above problems, the database connection pooling technology can be adopted. The basic idea of a database connection pool is to establish a "buffer pool" for database connections. A certain number of connections are pre-placed in the buffer pool, and when a database connection needs to be established, simply take one out of the buffer pool and put it back when you are finished. We can prevent the system from endlessly connecting to the database by setting the maximum number of connections to the connection pool. More importantly, we can monitor the number of connections in the database through the connection pool management mechanism ﹑ usage, provide the basis for system development ﹑ test and performance adjustment.

C3P0 is an open source JDBC connection pool, which is published in the Lib directory with Hibernate, including statement objects that implement the connection and datasources pools of JDBC3 and JDBC2 extension specification descriptions. (Home: http://sourceforge.net/projects/c3p0/)

BONECP is an open source, fast JDBC connection pool. BONECP is very small, only more than 40 K (runtime needs log4j and Google Collections support, which add up is not small), compared to c3p0 more than 600 K. Another person thinks that BONECP has a disadvantage is that the JDBC driver is loaded outside the connection pool, so that some application server configuration is not flexible. Of course, small volume is not bonecp excellent reason, BONECP in the end there is what prominent place, please see Performance test report. (Home: http://jolbox.com/)

DBCP (Database Connection pool) is a pool of databases that relies on the Jakarta Commons-pool object pooling mechanism, and the Tomcat data source uses DBCP. Currently, there are two versions of DBCP, 1.3 and 1.4, respectively. Version 1.3 corresponds to JDK 1.4-1.5 and JDBC 3, while the 1.4 version corresponds to JDK 1.6 and JDBC 4. So when choosing a version, look at what JDK version you're using, and there's no difference in functionality. (Home: http://commons.apache.org/dbcp/)

Proxool is a Java SQL driver driver that provides a connection pooling package for other types of drivers that you choose. Can be ported to existing code very simply. Fully configurable. Fast, mature and robust. You can transparently increase the connection pooling capability for your existing JDBC driver. (Home: http://proxool.sourceforge.net/)

[Java EE] Understanding Java connection pooling

Related Article

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.