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

So I'd write something more like:

  if (aoPreparedStatement != null)
  {
    aoPreparedStatement.close();
    aoPreparedStatement = null;
  }
  if (aoConnection != null)
  {
    aoConnection.close();
    aoConnection = null;
  }

thanks,

bryan


Reply via email to