The role of the database connection pool and the considerations when designing the connection pool.

Source: Internet
Author: User
The database connection pool is responsible for allocating, managing, and releasing database connections. During database connection pool initialization, a certain number of database connections are created and placed in the connection pool, the number of connections to these databases is set by the minimum number of connections to the database. Whether or not these database connections are used, the connection pool will always have at least so many connections. The maximum number of database connections in the connection pool limits the maximum number of connections that the connection pool can occupy. When the number of connections requested by the application to the connection pool exceeds the maximum number of connections, these requests will be added to the waiting queue. The following factors must be taken into account when setting the minimum number of connections and maximum number of connections in the database connection pool:
1) The minimum number of connections is the database connection that has been maintained by the connection pool. Therefore, if the application uses a small amount of database connections, a large amount of database connection resources will be wasted;
2) the maximum number of connections is the maximum number of connections that can be applied by the connection pool. If the number of database connection requests exceeds this limit, the subsequent database connection requests will be added to the waiting queue, which will affect subsequent database operations.
Java provides many container classes for us to easily build connection pools, such as vector and stack.
2. What is the working mechanism of the data connection pool?
When the J2EE server is started, a certain number of pool connections will be established, and a certain number of pool connections will be maintained. When the client program needs to connect, the pool driver returns an unused pool connection and marks it as "busy ". If no idle connection exists, the pool driver creates a certain number of connections. The number of new connections is determined by the configuration parameters. After the pool connection call is completed, the pool driver records the connection table as "idle". Other calls can use this connection.

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.