Week four jobs-database connection pool

Source: Internet
Author: User

Database connection pool This concept in the last semester when the experiment of the Java EE came into contact with, at that time only to understand the concept of the term, and do not really go into the use, the course needs to do the project will inevitably require a lot of access to database resources, considering the system's access optimization, began to regain the connection pool this tool.

Database connection is an expensive resource in application development, the optimization of his operation has a direct impact on the performance and robustness of the whole system, the connection pool is an important concept proposed for the optimization of this key resource, he first creates a new quantitative database connection, and dynamically allocates the connection when the application needs to access the database. , reuse after use, rather than frequent new and closed connections, provide good database performance assurance for applications based on FIFO-First order of service.

Traditional Java connection database directly using MySQL JDBC (Java Data Base Connectivity), this is a simple and rude method, the program directly control the database connection, need access to connect from the database server, perform the required operation after the release of the connection, This may be a viable option in small local programs or in projects with low concurrency requirements, which can withstand 100 or so concurrent accesses at that time, but only for a short period of time, but for a long period of high load, the entire system will not be able to escape paralysis.

There are two types of database connection pools that I know of, namely the DBCP connection pool and the C3P0 connection pool.

DBCP is an open source connection pool provided by Apache, and Tomcat is the default DBCP connection pool for his own brother, DBCP can be used standalone or integrated with application servers.

C3P0 is also an open source JDBC connection pool that is primarily used in the Hibernate development framework.

The difference between DBCP and c3p0:

DBCP does not automatically reclaim idle connection mechanism, need the user to voluntarily release;

C3P0 has automatic detection of idle connections and recovery capabilities;

DBCP and C3P0 Two database connection pools manage connections differently, C3P0 provides maximum idle time, disconnects when the connection exceeds maximum idle time, and DBCP provides the maximum number of connections.

This article is written after the reference http://www.cnblogs.com/xdp-gacl/p/4002804.html completes the connection pool configuration.

Week four jobs-database connection pool

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.