commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <phil.ste...@gmail.com>
Subject Re: DBCP - unclosed connections
Date Wed, 10 Nov 2010 10:44:14 GMT
On 11/8/10 7:19 PM, Tyson Lowery wrote:
> I have a JSP page that is getting reported for not closing
> connections in catalina.out. I'm running Tomcat 6.0.26, so I believe
> we are on DBCP 1.2. I've racked my brain trying to figure out how
> these connections could possible remain unclosed. Does anyone have
> any tips or suggestions on how I can further troubleshoot this?
>

If your page holds onto a connection for longer than 55 seconds or 
there are queries taking longer than 55 seconds to execute, DBCP 
will consider the associated connection abandoned.  Try increasing 
this setting.  Note also that maxWait is specified in milliseconds, 
so below is a pretty low setting.

Phil

> Here's the latest version of our connection pool settings:
> <Resource name="jdbc/myDB" auth="Container" type="javax.sql.DataSource"
> maxActive="350" maxIdle="40" minIdle="10" maxWait="45"
> removeAbandoned="true"
> removeAbandonedTimeout="55"
> validationQuery="select 1"
> testWhileIdle="true"
> testOnBorrow="true"
> logAbandoned="true"
> timeBetweenEvictionRunsMillis="100000"
> minEvictableIdleTimeMillis="400000"
> numTestsPerEvictionRun="3"
> username="user" password="password"
> driverClassName="com.mysql.jdbc.Driver"
> url="jdbc:mysql://1.2.3.4/myDB?autoReconnect=true&amp;jdbcCompliantTruncation=false"/>
>
>
>
> The JSP page literally has everything enclosed in a try block and
> all connections closed in a finally statement. See below:
>
> Connection con = null;
> Statement stmt = null;
> ResultSet rset = null;
> String query = "";
> Statement stmt2 = null;
> ResultSet rset3 = null;
> try {
> // page executes
> }
> catch (SQLException ex) {
> out.println ("\n*** SQLException caught ***\n");
> while (ex != null) {
> out.println ("SQLState: " + ex.getSQLState ());
> out.println ("Message: " + ex.getMessage ());
> out.println ("Vendor: " + ex.getErrorCode ());
> ex = ex.getNextException ();
> out.println ("");
> }
> }
> catch (java.lang.Exception ex) { // Got some other type of
> exception. Dump it.
> ex.printStackTrace ();
> }
> finally {
> if(rset != null) {
> try {rset.close();}
> catch(Exception e) {
> System.out.println("Exception in finally rset");
> e.printStackTrace();
> }
> rset = null;
> }
> if(rset3 != null) {
> try {rset3.close();}
> catch(Exception e) {
> System.out.println("Exception in finally rset3");
> e.printStackTrace();
> }
> rset3 = null;
> }
> if(stmt != null) {
> try {stmt.close();}
> catch(Exception e) {
> System.out.println("Exception in finally stmt");
> e.printStackTrace();
> }
> stmt = null;
> }
> if(stmt2 != null) {
> try {stmt2.close();}
> catch(Exception e) {
> System.out.println("Exception in finally stmt2");
> e.printStackTrace();
> }
> stmt2 = null;
> }
> if(con != null) {
> try {con.close();}
> catch(Exception e) {
> System.out.println("Exception in finally con");
> e.printStackTrace();
> }
> con = null;
> }
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message