You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Shailender Jain <sh...@teleatlas.com> on 2005/05/09 12:26:43 UTC

Connection Leakage

Hello All,

I have got a application which is running live. (Struts with the usage
of DBCP for connection pooling)

We have found a problem that at many places we have not closed the
connections.
To solve this problem we thought of increasing the number of Maximum
active connection.
We are also  thinking if there is a way by which we can configure the
connection pool so  that it
should close the connection after some time if it is not done by the
code.

Thanks
Shailender Jain



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


RE: Connection Leakage

Posted by Mark Benussi <ma...@hotmail.com>.
Shailender

You can configure your connection pool to close resources after a period of
time with the following options:

GenericObjectPool genericObjectPool = new GenericObjectPool(null);
genericObjectPool.setMaxActive(value);
genericObjectPool.setMaxIdle(value);
genericObjectPool.setMaxWait(value);

Defined here:
 
http://jakarta.apache.org/commons/pool/apidocs/org/apache/commons/pool/impl/
GenericObjectPool.html

However not closing you connections is bad practice. You should not
configure the GenericObjectPool to close your resources as a way of escaping
bad code. I guess must people will tell you the same thing. Imagine if you
did not pool your Database resources, you would end up with an application
with no connections available.

Always in your finally do:

try {
	conn.close();
} catch (Throwable te) {
	// Unecessary catch block
}

Regards,

Mark

-----Original Message-----
From: Shailender Jain [mailto:shailender.jain@teleatlas.com] 
Sent: 09 May 2005 11:27
To: user@struts.apache.org
Subject: Connection Leakage

Hello All,

I have got a application which is running live. (Struts with the usage
of DBCP for connection pooling)

We have found a problem that at many places we have not closed the
connections.
To solve this problem we thought of increasing the number of Maximum
active connection.
We are also  thinking if there is a way by which we can configure the
connection pool so  that it
should close the connection after some time if it is not done by the
code.

Thanks
Shailender Jain



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


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