Package javax.transaction.xa

Examples of javax.transaction.xa.XAException


        String sqlstate = se.getSQLState();
        String message = se.getMessage();
        int seErrorCode = se.getErrorCode();     
        int xaErrorCode;
       
        XAException xae;
       
        // Determine the XAException.errorCode.  This is known for
        // some specific exceptions. For other exceptions, we will
        // return XAER_RMFAIL for SESSION_SEVERITY or greater and
        // XAER_RMERR for less severe errors. DERBY-4141.
        if (sqlstate.equals(StandardException.getSQLStateFromIdentifier(
                            SQLState.STORE_XA_XAER_DUPID)))
            xaErrorCode = XAException.XAER_DUPID;
        else if (sqlstate.equals(StandardException.getSQLStateFromIdentifier(
                                SQLState.STORE_XA_PROTOCOL_VIOLATION)))
            xaErrorCode = XAException.XA_RBPROTO;
        else if (sqlstate.equals(SQLState.DEADLOCK))
            xaErrorCode = XAException.XA_RBDEADLOCK;
        else if (sqlstate.equals(SQLState.LOCK_TIMEOUT))
            xaErrorCode = XAException.XA_RBTIMEOUT;
        else if (seErrorCode >=  ExceptionSeverity.SESSION_SEVERITY)
            xaErrorCode = XAException.XAER_RMFAIL;           
        else
            xaErrorCode = XAException.XAER_RMERR;
       
        xae = new XAException(message);
        xae.errorCode = xaErrorCode;
        if (JVMInfo.JDK_ID >= JVMInfo.J2SE_14)
            xae.initCause(se);
        return xae;
    }
View Full Code Here


    }

    public void join(Xid xid, XAResource xaRes) throws XAException {
        Set resSet = (Set) xids.get(xid);
        if (resSet == null) {
            throw new XAException(XAException.XAER_NOTA);
        }
        resSet.add(xaRes);
    }
View Full Code Here

        resSet.add(xaRes);
    }

    public void newTx(Xid xid, XAResource xaRes) throws XAException {
        if (xids.containsKey(xid)) {
            throw new XAException(XAException.XAER_DUPID);
        }
        Set resSet = new HashSet();
        resSet.add(xaRes);
        xids.put(xid, resSet);
    }
View Full Code Here

        xids.put(xid, resSet);
    }

    public void forget(Xid xid, XAResource xaRes) throws XAException {
        if (xids.remove(xid) == null) {
            throw new XAException(XAException.XAER_NOTA);
        }
    }
View Full Code Here

        return currentXid;
    }

    public void start(Xid xid, int flags) throws XAException {
        if (this.currentXid != null) {
            throw new XAException(XAException.XAER_PROTO);
        }
        if (flags == XAResource.TMRESUME && !knownXids.contains(xid)) {
            throw new XAException(XAException.XAER_PROTO);
        }
        if (finishedXids.contains(xid)) {
            throw new XAException(XAException.XAER_PROTO);
        }
        if ((flags & XAResource.TMJOIN) != 0) {
            manager.join(xid, this);
        } else {
            manager.newTx(xid, this);
View Full Code Here

        }
    }

    public void end(Xid xid, int flags) throws XAException {
        if (!knownXids.contains(xid)) {
            throw new XAException(XAException.XAER_PROTO);
        }
        if (flags == XAResource.TMSUSPEND) {
            if (currentXid == null) {
                throw new XAException(XAException.XAER_PROTO);
            } else if (this.currentXid != xid) {
                throw new XAException(XAException.XAER_PROTO);
            }
        } else if (flags == XAResource.TMFAIL || flags == XAResource.TMSUCCESS) {
            if (finishedXids.contains(xid)) {
                throw new XAException(XAException.XAER_PROTO);
            }
            finishedXids.add(xid);
        }
        this.currentXid = null;
    }
View Full Code Here

        this.currentXid = null;
    }

    public int prepare(Xid xid) throws XAException {
        if (!finishedXids.contains(xid)) {
            throw new XAException(XAException.XAER_PROTO);
        }
        prepared = true;
        preparedXids.add(xid);
        return XAResource.XA_OK;
    }
View Full Code Here

        return XAResource.XA_OK;
    }

    public void commit(Xid xid, boolean onePhase) throws XAException {
        if (!finishedXids.contains(xid)) {
            throw new XAException(XAException.XAER_PROTO);
        }
        preparedXids.remove(xid);
        committed = true;
    }
View Full Code Here

        committed = true;
    }

    public void rollback(Xid xid) throws XAException {
        if (!finishedXids.contains(xid)) {
            throw new XAException(XAException.XAER_PROTO);
        }
        rolledback = true;
        preparedXids.remove(xid);
        manager.forget(xid, this);
    }
View Full Code Here

        return new Xid[0];
    }

    public void rollback(Xid xid) throws XAException {
        if (this.xid == null || !this.xid.equals(xid)) {
            throw new XAException();
        }
        try {
            localTransaction.rollback();
        } catch (ResourceException e) {
            throw (XAException)new XAException().initCause(e);
        } finally {
            this.xid = null;
        }
    }
View Full Code Here

TOP

Related Classes of javax.transaction.xa.XAException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.