Package javax.transaction.xa

Examples of javax.transaction.xa.Xid


                PreparedStatement ps = connection.prepareStatement(RECOVER);
                try {
                    ps.setString(0, systemId);
                    ResultSet rs = ps.executeQuery();
                    try {
                        Xid lastXid = null;
                        Xid currentXid = null;
                        Recovery.XidBranchesPair xidBranchesPair = null;
                        while (rs.next()) {
                            int formatId = rs.getInt(0);
                            byte[] globalId = rs.getBytes(1);
                            byte[] globalBranchId = rs.getBytes(2);
                            byte[] branchBranchId = rs.getBytes(3);
                            String name = rs.getString(4);
                            currentXid = xidFactory.recover(formatId, globalId, globalBranchId);
                            Xid branchXid = xidFactory.recover(formatId, globalId, branchBranchId);
                            if (!currentXid.equals(lastXid)) {
                                xidBranchesPair = new Recovery.XidBranchesPair(currentXid, null);
                                recovered.add(xidBranchesPair);
                                lastXid = currentXid;
                            }
View Full Code Here


    //Build the SYNNCTL commit command
    public void writeLocalXACommit(NetConnection conn) throws SqlException {
        NetXACallInfo callInfo =
                conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
        Xid xid = callInfo.xid_;
        buildSYNCCTLMigrate();   // xa migrate to resync server
        buildSYNCCTLCommit(CodePoint.TMLOCAL, xid);   // xa local commit
    }
View Full Code Here

        buildSYNCCTLRollback(CodePoint.TMLOCAL);   // xa local rollback
    }

    public void writeXaStartUnitOfWork(NetConnection conn) throws SqlException {
        NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
        Xid xid = callInfo.xid_;
        int xaFlags = callInfo.xaFlags_;
        long xaTimeout = callInfo.xaTimeoutMillis_;

        // create DSS command with reply.
        createCommand();

        // save the length bytes for later update
        markLengthBytes(CodePoint.SYNCCTL);

        // SYNCTYPE
        writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_NEW_UOW);

        if (xid.getFormatId() != -1) {
            writeXID(CodePoint.XID, xid);
        } else
        // write the null XID for local transaction on XA connection
        {
            writeNullXID(CodePoint.XID);
View Full Code Here

        updateLengthBytes();
    }

    public void writeXaEndUnitOfWork(NetConnection conn) throws SqlException {
        NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
        Xid xid = callInfo.xid_;
        int xaFlags = callInfo.xaFlags_;

        createCommand();

        // save the length bytes for later update
        markLengthBytes(CodePoint.SYNCCTL);

        // SYNCTYPE
        writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_END_UOW);

        if (xid.getFormatId() != -1) {
            writeXID(CodePoint.XID, xid);
        } else
        // write the null XID for local transaction on XA connection
        {
            writeNullXID(CodePoint.XID);
View Full Code Here

        updateLengthBytes();
    }

    protected void writeXaPrepare(NetConnection conn) throws SqlException {
        NetXACallInfo callInfo = conn.xares_.callInfoArray_[conn.currXACallInfoOffset_];
        Xid xid = callInfo.xid_;
        // don't forget that xars.prepare() does not have flags, assume TMNOFLAGS
        int xaFlags = XAResource.TMNOFLAGS;

        createCommand();

        // save the length bytes for later update
        markLengthBytes(CodePoint.SYNCCTL);

        // SYNCTYPE
        writeSYNCType(CodePoint.SYNCTYPE, CodePoint.SYNCTYPE_PREPARE);

        if (xid.getFormatId() != -1) {
            writeXID(CodePoint.XID, xid);
        } else
        // write the null XID for local transaction on XA connection
        {
            writeNullXID(CodePoint.XID);
View Full Code Here

    protected void setUp() throws Exception {
        tm = new TransactionManagerImpl(10 * 1000, null, null);
    }

    public void testImportXid() throws Exception {
        Xid externalXid = xidFactory.createXid();
        Transaction tx = tm.importXid(externalXid, 0);
        assertNotNull(tx);
        assertEquals(Status.STATUS_ACTIVE, tx.getStatus());
    }
View Full Code Here

        assertNotNull(tx);
        assertEquals(Status.STATUS_ACTIVE, tx.getStatus());
    }

    public void testNoResourcesCommitOnePhase() throws Exception {
        Xid externalXid = xidFactory.createXid();
        Transaction tx = tm.importXid(externalXid, 0);
        tm.commit(tx, true);
        assertEquals(Status.STATUS_NO_TRANSACTION, tx.getStatus());
    }
View Full Code Here

        tm.commit(tx, true);
        assertEquals(Status.STATUS_NO_TRANSACTION, tx.getStatus());
    }

    public void testNoResourcesCommitTwoPhase() throws Exception {
        Xid externalXid = xidFactory.createXid();
        Transaction tx = tm.importXid(externalXid, 0);
        assertEquals(XAResource.XA_RDONLY, tm.prepare(tx));
        assertEquals(Status.STATUS_NO_TRANSACTION, tx.getStatus());
    }
View Full Code Here

        assertEquals(XAResource.XA_RDONLY, tm.prepare(tx));
        assertEquals(Status.STATUS_NO_TRANSACTION, tx.getStatus());
    }

    public void testNoResourcesMarkRollback() throws Exception {
        Xid externalXid = xidFactory.createXid();
        Transaction tx = tm.importXid(externalXid, 0);
        tx.setRollbackOnly();
        try {
            tm.prepare(tx);
            fail("should throw rollback exception in an XAException");
View Full Code Here

        }
        assertEquals(Status.STATUS_NO_TRANSACTION, tx.getStatus());
    }

    public void testNoResourcesRollback() throws Exception {
        Xid externalXid = xidFactory.createXid();
        Transaction tx = tm.importXid(externalXid, 0);
        tm.rollback(tx);
        assertEquals(Status.STATUS_NO_TRANSACTION, tx.getStatus());
    }
View Full Code Here

TOP

Related Classes of javax.transaction.xa.Xid

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.