db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Pendleton <bpendle...@amberpoint.com>
Subject Re: Problem in release connection
Date Wed, 21 Mar 2007 16:35:16 GMT
> provided by derby. Following are the code I am using for clean the 
> database connection and also PreparedStatement.
>             if(!(aoConnection ==null || aoConnection.isClosed()))
>                 aoConnection.close();//Release Connection
>             if(aoPreparedStatement != null)
>                 aoPreparedStatement.close();

I think it would be better to close the statement before
you close the connection.

I also tend not to bother with calling isClosed methods. Instead
I set the variable to null after I close the connection. I think
that might also help the garbage collector find more garbage to

So I'd write something more like:

   if (aoPreparedStatement != null)
     aoPreparedStatement = null;
   if (aoConnection != null)
     aoConnection = null;



View raw message