JDBC of Java Technology Review: Connection pool __java

Source: Internet
Author: User
Tags connection pooling event listener

JDBC Connection pool framework
in enterprise database applications, the database connection pool (Connection pool) is a very important component. The primary function of the connection pool is to manage and control several types of resources in JDBC (connection,statement,resultset) to provide high-performance database access while preventing the unrestricted use of these types of resources, resulting in performance degradation and even service crashes. Connection pool generally has the maximum number of connections, the minimum number of connections, the maximum number of concurrent connections and other attributes. Before JDBC3.0 the connection pool framework, some application servers and database vendors provided their own connection pooling components, and customers might have different configurations when using different connection pooling services. The JDBC3.0 specification defines the framework for a standard connection pool and several standard attributes.

The

JDBC Connection pool API
pooledconnection   represents a physical connection to the data source. It is managed by ConnectionPoolDataSource and can be reused. In contrast, the connection we use every day is called a logical connection.
connectionpooldatasource   Connection pool data source, which manages the Pooledconnection factory.
ConnectionEvent   The event that is generated when a pooledconnection connection is closed, or when an error occurs. The
Connectioneventlistener  connectionevent event listener.
The above APIs are oriented to application servers and JDBC drivers, and unless you are implementing your own connection pool, applications that use JDBC generally will not and should not deal with these interfaces, or face standard datasource,connection interfaces. When our application invokes the DataSource getconnection () method to obtain connection, it actually obtains a poolconnection handle from the connection pool. The actual poolconnection may be already existing in the connection pool, or it may be newly created, and the application will not know. When the close () method of the connection is invoked, only the logical connection is closed, and the actual poolconnection is returned to the pool for reuse.

Open source Connection pool implementation
currently has a large number of open source connection pool implementations, most of them are relatively independent components, through a certain configuration can be used in our applications. Here are three more used connection pools:
DBCP   It is the database connection pool that has been brought up in Tomcat.
c3p0   It is a database connection pool developed along with Hibernate.
Proxool   It is a JAVA SQL driver driver that provides a variety of JDBC-driven connection pooling packages.
The above several connection pool configuration method is very similar, each has its own strengths, can be based on specific applications and a variety of evaluation data to choose.

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.