db-ojb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jair da Silva Ferreira JĂșnior ...@amazon.com.br>
Subject gracefuly recover from an exception in transaction.commit()
Date Fri, 03 Oct 2003 04:03:05 GMT
Hi,
    I am using ojb1.0_rc4, ODMG api with OJB queries and mysql4. I have a problem on how to
recover from an exception thrown inside the commit of an ODMG transaction. Please see the
above example code and follow the comments.

    Transaction t=null;
    try{
        t=implementation.newTransaction();
        t.begin();

        // do something...

        t.commit(); //an exception is thrown here! usually the exception root cause is an
SQLException
    }
    catch(Exception e){
        //log exception
        if(t!=null){
            t.abort(); //here a NullPointerException is thrown. why?
        }
    }

    the stack trace of the NullPointerException thrown in t.abort() is:
        java.lang.NullPointerException
            at org.apache.ojb.odmg.TransactionImpl.doClose(Unknown Source)
            at org.apache.ojb.odmg.TransactionImpl.abort(Unknown Source)
            ...

    Can somebody help me on how to gracefuly recover from an exception in commit? Am I doing
something wrong?

    Any help would be appreciated.

Thanks,
    Jair Jr

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message