public int prepare ( Xid xid ) throws XAException { validateXid ( xid ) ; /** * @todo: This is where the real 2-phase work should be done to * determine if a commit done here would succeed or not. */ /** * @todo: May improve performance to return XA_RDONLY whenever * possible, but I don't know. * Could determine this by checking if DB instance is in RO mode, * or perhaps (with much difficulty) to determine if there have * been any modifications performed. */ if ( state != XA_STATE_ENDED ) { throw new XAException ( "Invalid XAResource state" ) ; } // throw new XAException( // "Sorry. HSQLDB has not implemented 2-phase commits yet"); state = XA_STATE_PREPARED ; return XA_OK ; // As noted above, should check non-committed work. }
Vote on whether to commit the global transaction .