commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Zoetebier <john.zoeteb...@transparent.co.nz>
Subject Re: DBCP question: what is closing the actual database connection ?
Date Sun, 09 Nov 2003 05:31:50 GMT
On Sun, 9 Nov 2003 03:56:15 +0200, Schalk <schalk@volume4.co.za> wrote:

> John
>
> In basic situation you will have:
> Class.forName(DRIVER);
> con = DriverManager.getConnection(URL,USER,PASS);
>
> At the end you will have:
> finally {
>     try {	
>     if (con != null)
>         con.close();
> 	} catch (SQLException ex) {
>             out.println("\nERROR:------ SQLException -----\n");
>             out.println("Message: " + ex.getMessage());
>             out.println("SQLState: " + ex.getSQLState());
>             out.println("ErrorCode :" + ex.getErrorCode());
>         }
>             }
>

The result of con.close() is that the connection is returned to the 
connection pool.
This is the purpose of connection pooling: reuse of a connection to 
increase performance.
However at program shutdown something needs to close the "real" connection 
in the connection pool.

My question is:
- is closing of connections in the pool handled automatically by Jakarta 
Commons DBCP ?
- or do I have do something manaully to close the connections in the 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


Mime
View raw message