TomohitoNakayama wrote:

> Hello.
>
> I annotated org.apache.derby.impl.drda.Database.java and
> found call of conn.rollback() exists from "Initial code import"...
>
> 37083       coar  protected void close() throws SQLException
> 37083       coar  {
> 37083       coar
> 37083       coar   try {
> 37083       coar    if (stmtTable != null)
> 37083       coar    {
> 37083       coar     for (Enumeration e = stmtTable.elements() ;
> e.hasMoreElements() ;)
> 37083       coar     {
> 37083       coar      ((DRDAStatement) e.nextElement()).close();
> 37083       coar     }
> 37083       coar
> 37083       coar    }
> 37083       coar    if (defaultStatement != null)
> 37083       coar     defaultStatement.close();
> 37083       coar    if ((conn != null) && !conn.isClosed())
> 37083       coar    {
> 37083       coar     conn.rollback();
> 37083       coar     conn.close();
> 37083       coar    }
> 37083       coar   }
> 37083       coar   finally {
> 37083       coar    conn = null;
> 37083       coar    currentStatement = null;
> 37083       coar    defaultStatement = null;
> 37083       coar    stmtTable=null;
> 37083       coar   }
> 37083       coar  }
>
> Hmm....
> This calling conn.rollback() seems to have history ....
>
In Derby when you close a connection, the close will fail if there is an
active transaction, so the rollback is needed to allow the connection to
close properly.
Yes, there is a history which is that  the rollback was not needed on
connection close in a previous incarnation of the Cloudscape product. 
The rollback  had to be added to ensure the connections were closed
properly.

Kathey




Reply via email to