Tomcat database connection pool, closed after connection is used up

Source: Internet
Author: User

In general, the database connection pool is configured in Tomcat, and we constantly establish database connections. This is the case if the database connection is not closed.
Common: cannot get a connection, pool exhaustedcannot get a connection, pool
Exhausted
. In fact, this is because the connections in the connection pool are exhausted. In fact, we should develop a good habit in development, that is, we should close the connection immediately after the connection is used up.
This is a good solution.


Some people may say that the database connection should be closed every time the pool connection is used up, so the pool will not work anymore? Isn't it because the connection is closed once and the connection is established again? Isn't the efficiency still low?
Otherwise, call con. close () does not actually close the connection, but allows the pool to store the connection back to the pool and allocate it to other clients for use.
And does not affect the efficiency of the connection pool.

Of course, this is not the only solution, but I think it is the best solution. However, if you forget to close the database connection during programming, there are still other solutions: (of course, it is best to disable con in finally)

1. You can restart your Tomcat server. This is the best solution, but it has no technical skills.
2. In the configuration file of the data source, adjust the value of the maxactive attribute to a greater value, such as 100

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.