--- Craig McClanahan <[EMAIL PROTECTED]> wrote:

> Calling BasicDataSource.close() will only close the connections still
> in the pool -- not the ones that have been checked out.  It is
> designed to be called only when your app is ready to shut down.
> 
> For normal usage, the best approach is something like this:
> 
>     DataSource ds = ... get your data source reference;
>     Connection conn = null;
>     try {
>         conn = ds.getConnection();
>         ... use the connection as needed ...
>         conn.close(); // Returns this connection to the pool
>     } catch (SQLException e) {
>         ... deal with any exception ...
>     } finally {
>         if (conn != null) {
>             try {
>                 conn.close();
>             } catch (SQLException e) {
>                 ...
>             }
>         }
>     }

It's this kind of drudgery that prompted me to volunteer on DbUtils. 
Check it out if you're tired of JDBC resource cleanup.

http://jakarta.apache.org/commons/dbutils/

David


> 
> That way, you're always returning the connection to the pool, even if
> an exception occurs while you're using it.
> 
> BTW, your MySQL admin will show active connections for all the entries
> in the pool, as well as those that have been checked out and are in
> use.
> 
> Craig
> 
> On Thu, 10 Feb 2005 10:14:17 -0800, Paul Hsu <[EMAIL PROTECTED]>
> wrote:
> > Hi,
> > 
> > I have one question about DBCP. I like to know if any one have used
> BasicDataSource.close(). In my program I set up a BasicDataSource and
> get connection from MYSQL, I call BasicDataSource.close() right after
> get connection, I still see the connectioin from MYSQL admin. I just
> wonder this function is working?
> > 
> > thanks,
> > 
> > Paul
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 



                
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to