Package javax.transaction

Examples of javax.transaction.UserTransaction


     * @throws TransactionException if a rollback was made.
     */
    public void deleteTableWithBeginCommit(final boolean callOnlyTransaction, final String dbName) throws SQLException,
            NamingException, SystemException, NotSupportedException, HeuristicRollbackException, RollbackException,
            HeuristicMixedException, TransactionException {
        UserTransaction utx = TransactionHelper.getUserTransaction();
        utx.begin();
        try {
            if (!callOnlyTransaction) {
                TableManager tableManager = new TableManager(dbName);
                tableManager.deleteTable(TABLE);
            }
            utx.commit();
        } catch (Exception e) {
            utx.rollback();
            throw new TransactionException("Error during commit.", e);
        }

    }
View Full Code Here


     *         relevant update was commited and others rolled back.
     */
    public void deleteTableWithoutBegin(final boolean callOnlyTransaction, final String dbName) throws SQLException,
            NamingException, SystemException, NotSupportedException, HeuristicRollbackException, RollbackException,
            HeuristicMixedException {
        UserTransaction utx = TransactionHelper.getUserTransaction();
        if (!callOnlyTransaction) {
            TableManager tableManager = new TableManager(dbName);
            tableManager.deleteTable(TABLE);
        }
        utx.commit();

    }
View Full Code Here

     * @throws TransactionException if a rollback was made.
     */
    public void insertTableWithBeginCommit(final boolean callOnlyTransaction, final String dbName) throws SQLException,
            NamingException, SystemException, NotSupportedException, HeuristicRollbackException, RollbackException,
            HeuristicMixedException, TransactionException {
        UserTransaction utx = TransactionHelper.getUserTransaction();
        utx.begin();
        try {
            if (!callOnlyTransaction) {
                TableManager tableManager = new TableManager(dbName);
                tableManager.insertTable(TABLE);
            }
            utx.commit();
        } catch (Exception e) {
            utx.rollback();
            throw new TransactionException("Error during commit.", e);
        }

    }
View Full Code Here

     * @throws SystemException if an unexpected error occurs.
     * @throws NotSupportedException if the resquest cannot be made.
     */
    public void insertTableWithoutCommit(final boolean callOnlyTransaction, final String dbName) throws SQLException,
            NamingException, SystemException, NotSupportedException {
        UserTransaction utx = TransactionHelper.getUserTransaction();
        utx.begin();
        if (!callOnlyTransaction) {
            TableManager tableManager = new TableManager(dbName);
            tableManager.insertTable(TABLE);
        }
    }
View Full Code Here

         ConnectionFactory mcf =
            (ConnectionFactory)initialContext.lookup("java:/JCAConnectionFactory");
         Connection conn = mcf.createConnection();
         conn.start();

         UserTransaction ut = ServerManagement.getUserTransaction();

         ut.begin();

         Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageProducer p = s.createProducer(queue);
         Message m = s.createTextMessage("one");

         p.send(m);

         ut.commit();

         conn.close();

         ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("ConnectionFactory");
         conn = cf.createConnection();
View Full Code Here

     * @output an EJBException.
     * @throws Exception if an error occurs.
     */
    @Test(expectedExceptions = javax.ejb.EJBException.class)
    public void testClassDefinition() throws Exception {
        UserTransaction utx = TransactionHelper.getInternalUserTransaction();
        try {
            utx.begin();
            slsbCMTInheritance.dummyMethod1();
        } finally {
            utx.rollback();
        }
    }
View Full Code Here

     * @output a correct method execution.
     * @throws Exception if an error occurs.
     */
    @Test
    public void testOverrideSuperclassDefinition2() throws Exception {
        UserTransaction utx = TransactionHelper.getInternalUserTransaction();
        try {
            utx.begin();
            slsbCMTInheritance.dummyMethod4();
        } finally {
            utx.rollback();
        }
    }
View Full Code Here

     * @throws NamingException if a problem to get the transaction occurs.
     * @throws NotSupportedException if the bean is already associated with a transaction.
     * @throws SystemException if an unexpected error occurs during the transaction.
     */
    public void openTransaction() throws NamingException, NotSupportedException, SystemException {
        UserTransaction utx = TransactionHelper.getUserTransaction();
        utx.begin();
    }
View Full Code Here

    /**
     * Makes a rollback in the transaction that is active.
     * @throws Exception if an error occurs during the rollback.
     */
    public static void cleanTransaction() throws Exception {
        UserTransaction utx = TransactionHelper.getInternalUserTransaction();
        try {
            if (transactionIsActive()) {
                utx.rollback();
            }
        } catch (Exception e) {
            throw new Exception("Cannot clean the transaction. The test cannot be started", e);
        }
    }
View Full Code Here

     *         relevant update was commited and others rolled back.
     * @throws TransactionException if a rollback was made.
     */
    public void verifyBMT() throws IllegalStateException, SecurityException, HeuristicMixedException,
            HeuristicRollbackException, RollbackException, SystemException, NotSupportedException, NamingException {
        UserTransaction utx = TransactionHelper.getUserTransaction();
        utx.begin();
        utx.commit();
    }
View Full Code Here

TOP

Related Classes of javax.transaction.UserTransaction

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.