Cannot get a connection, pool exhausted solution

Source: Internet
Author: User
Yesterday looked at the database connection pool, there are many open source connection pool, in order to facilitate the use of Tomcat with the connection pool,
Started looking for a few articles, did not succeed, the Tomcat graphics management interface to create a connection pool is also not good to use,
Later on the internet to find a piece of tomcat5.5 configuration article, finally is solved,
Follow the example below to try, refresh several times and then appear
Cannot get a connection, pool exhausted
Then a search was made that the connection pool was depleted,
Without closing con,
There are 3 solutions:
1 Restart Tomcat Server
2, maxactive the value of the big
3 Closing Conn in finally

Context Initctx=new InitialContext ();
DataSource ds = (DataSource) initctx.lookup ("Java:comp/env/jdbc/mysql");
C.getconnection ();
OUT.PRINTLN ("Query data from Database:<br>");
Statement stmt=conn.createstatement ();
ResultSet rs =stmt.executequery ("Select * from UserInfo");
while (Rs.next ())
{
Out.println (rs.getstring (1));
Out.println (rs.getstring (2));
}
Rs.close ();
Stmt.close ();
}
catch (Exception e)
{
E.printstacktrace ();
}
Finally
{
if (conn!=null)
Conn.close ();

}

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.