Hi Eric,

Sorry for my reply delayed.

> 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

As you pointed out, the following code may be safer:

     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!=null){
                     if(!conn.isClosed()){
                         xc.close();
                     }
                 }
             }
         }catch(java.sql.SQLException ex) {
             Trace.errln(ex.toString());
         }
     }

In case that the XAConnection.close() has already been called,
XAConnection.getConnection() returns null and this results in
NullPointerException.

But as long as I know, XAConnection.close() is invoked only in:

    private void destroyItem(PoolItem item) {
       hXAC2Item.remove(item.xaConn);
       try {
           item.xaConn.close();
       } catch (java.sql.SQLException ign) {
           Trace.errln(ign.toString());
       }
       item.xaConn = null;
    }

which is the method of ConnectionManager.Pool.
And in this case, such an instance of XAConnection is removed from
hXAC2Item (even when XAConnection.close() throws SQLException).
So we may not encounter the problem.

-- 
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".

Reply via email to