You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Zsolt Koppany <zk...@intland.com> on 2003/11/26 17:34:05 UTC

When does dbcp close a connection?

Hi,

I have looked into the dbcp sources and getConnection just returns a
java.sql.Connection object. Does that mean that connection.close closes the
connection to the database? If not, when will be the connection really
closed?

Zsolt



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


Re: When does dbcp close a connection?

Posted by John Zoetebier <jo...@transparent.co.nz>.
On Wed, 26 Nov 2003 17:34:05 +0100, Zsolt Koppany 
<zk...@intland.com> wrote:

> Hi,
>
> I have looked into the dbcp sources and getConnection just returns a
> java.sql.Connection object. Does that mean that connection.close closes 
> the
> connection to the database? If not, when will be the connection really
> closed?

Connection.close will return the connection to the pool.
After setting up DBCP yout code can basically stay the same.
To close the real connection to the database at application shutdown do:
connectionPool.close();

This will closed the actual connections to the databse.
I made a wrapper class for setting up DBCP and closing the connection pool.

-- 
John Zoetebier
Web site: http://www.transparent.co.nz

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