Tomcat JNDI Connection Pool Overflow

Source: Internet
Author: User
Tags tomcat

Recently received an urgent work, with 5 days to do a website.

Due to tight time, a lot of work too late to do more fine, the main function of a hurry to finish the line. Because there is no time to do more testing, so the heart can not help but have some worry about the website system. The results of the Web site is less than half a day, the most worrying thing still happened-the system hangs, the problem is not connected.

The error in the background report is:

Cannot get a connection, pool error Timeout waiting for idle object

Timeout Waiting for idle object

Obviously, the connection pool overflowed. Because the system has been officially online, to check the program where the connection is not in time to close may be too late, there is no simple way to do it.

So I checked the internet, and sure enough.

is a word removeabandoned= "true" removeabandonedtimeout= "logabandoned=" true "

Add this sentence to the resource configuration.

<resource name= "Datasourcejndi" auth= "Container"
Type= "Javax.sql.DataSource"
Password= "11111111"
Username= "SA"
Driverclassname= "Net.sourceforge.jtds.jdbc.Driver"
Url= "Jdbc:jtds:sqlserver://127.0.0.1:1433;databasename=web" maxactive= "maxidle=" maxWait= "5000" Removeabandoned= "true" removeabandonedtimeout= "a" logabandoned= "true"/>

This means that when the connection in the connection pool reaches 500 of the maximum number of connections, the connection that is idle for 60 seconds without proper shutdown is automatically recycled and information about the reclaimed connection is exported to the console.

Is that the case? First Test:

First of all, "maxactive=" maxidle= "30" change a little bit, maxactive= "ten" maxidle= "5"

Second, write a small program, this program to get connected does not normally shut down.

The test results are predictable: the console outputs a large number of hints when it takes up about 10 connections. The information indicates where the connection is not closed, and the test page is displayed normally.

OK, first of all, the next step to take time to test the system in detail.

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.