Summary of DBCP applications (2)

Source: Internet
Author: User
Summary of DBCP applications (2)

In this article, I 'd like to share with you how DBCP gets the connection.

First, my configuration is as follows:

Initialsize = 1 minidle = 1 maxidle = 2 maxactive = 20 # Whether the idle link verifies testwhileidle = true # validationquery = select 1 # When the connection is exhausted, how long will it take to recover lost connections maxwait = 1000 # Whether to automatically recycle the timeout connection removeabandoned = true # The timeout wait time is measured in milliseconds removeabandonedtimeout = 300 # Whether to print the connection when the timeout connection is automatically recycled logabandoned = true

Next let's take a look at the connection information of the database:

There are only two initial connections. When I query these connections, they can be used directly as long as they are idle. However, when I perform write operations, somehow, a new connection will be generated. To find the reason, I plan to start with the getconnection method to find out the actual problem. First, I found the sequence diagram on the official website:

The borrowobject method has the following logic:

If (config! = NULL & config. getremoveabandoned () & (getnumidle () <2) & (getnumactive ()> getmaxactive ()-3) {removeabandoned ();}

After the method is called, the number of connections remains unchanged.

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.