Hi,
I think its a good idea to do the following as well.

loop through connections(try put inside loop)
try {
    if(conn != null) {
        conn.close();
   }
catch(SQLException e) { print trace}
finally {
 conn = null;
}
end loop

This in my opinion is a little safer for resource clean up.

Thanks for asking for suggesstions
Eric :-)

Jun Inamori wrote:

> Hello,
> Thank you for your enthusiastic development.
>
> In the 18th April, I posted the patch for the following problem:
>
> PROBLEM: Closing the actual JDBC connection at shutdown
> The current implementation of ConnectionManager is responsible for
> closing the actual JDBS connection after the specified time passed. It
> is the great improvement since version 1.x . But there is the
> possibility that some connections remain opened at the server shutdown.
> This doesn't matter for most RDB, but as for InstantDB, it results in
> the problem. Anymore, it is desirable to close all the actual JDBC
> connection when the server is shutdown.
>
> And I found the mistake about my patch. It is in:
>
>     CLASS: org.objectweb.jonas.dbm.ConnectionManager
>     INNER_CLASS: Pool
>     METHOD: public void closeAllConnection()
>
> My old code was:
>     /**
>      * Adm.stopServer()
>      * -->DataBaseManager.unbindDataSources()
>      * -->ConnectionManager.closeAllConnection()
>      * -->Pool.closeAllConnection()
>      */
>     public void closeAllConnection(){
>         Trace.outln(trace,"Pool.closeAllConnection()");
>         Enumeration e=hXAC2Item.keys();
>         try{
>             while(e.hasMoreElements()) {
>                 XAConnection xc=(XAConnection)e.nextElement();
>                 Connection conn=xc.getConnection();
>                 if(!conn.isClosed()){
>                     conn.close();
>                 }
>             }
>         }catch(java.sql.SQLException ex) {
>             Trace.errln(ex.toString());
>         }
>     }
>
> But it should be:
>     /**
>      * Adm.stopServer()
>      * -->DataBaseManager.unbindDataSources()
>      * -->ConnectionManager.closeAllConnection()
>      * -->Pool.closeAllConnection()
>      */
>     public void closeAllConnection(){
>         Trace.outln(trace,"Pool.closeAllConnection()");
>         Enumeration e=hXAC2Item.keys();
>         try{
>             while(e.hasMoreElements()) {
>                 XAConnection xc=(XAConnection)e.nextElement();
>                 Connection conn=xc.getConnection();
>                 if(!conn.isClosed()){
>                     xc.close();
>                 }
>             }
>         }catch(java.sql.SQLException ex) {
>             Trace.errln(ex.toString());
>         }
>     }
>
> Note that we should invoke XAConnection.close() rather than
> Connection.close().
> Sorry for my mistake.
> Any questions and comments are welcome.
>
> PS:
> I'm not the member of this mailing list. I wish to join the list, but at
> this time, I have enough time to participate in.
> So, please mail to me([EMAIL PROTECTED]) directly!
>
> Happy Java programming!
> Jun Inamori
> E-mail: [EMAIL PROTECTED]
> URL:    http://www.oop-reserch.com
> ----
> This list is cross-posted to two mail lists.  To unsubscribe,
> follow the instructions below for the list you subscribed to.
> For objectweb.org: send email to [EMAIL PROTECTED] and
> include in the body of the message "unsubscribe ejb-container-group".
> For enhydra.org: send email to [EMAIL PROTECTED] and include
> in the body of the message "unsubscribe ejb-container-group".

----
This list is cross-posted to two mail lists.  To unsubscribe,
follow the instructions below for the list you subscribed to.
For objectweb.org: send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe ejb-container-group".
For enhydra.org: send email to [EMAIL PROTECTED] and include
in the body of the message "unsubscribe ejb-container-group".

Reply via email to