Package com.skyline.energy.exception

Examples of com.skyline.energy.exception.TransactionException


      } else if (txManager.isLazyBegin()) {// 仅懒启动式事务,第一次启动事务
        beginNewTransaction(dataSource, txObject);
        con = txObject.getConnectionHolder().getCurrentConnection();
        shouldAddCount = true;
      } else {
        throw new TransactionException("not lazyBegin transaction bu no currentConnection exist");
      }

      conHolder = txObject.getConnectionHolder(); // 重新获取ConnectionHolder
    }
View Full Code Here


      con = conHolder.getCurrentConnection();

      JdbcUtils.prepareConnectionForTransaction(newCon, txObject.getCurrentDefinition());
    } catch (Exception ex) {
      releaseConnection(con);
      throw new TransactionException("Could not open JDBC Connection for transaction", ex);
    }
  }
View Full Code Here

  }

  public static void commitTransaction(Connection con) throws SQLException {
    JdbcTransactionContext txObject = (JdbcTransactionContext) TransactionContextHolder.getContext();
    if (txObject == null) {// 不支持事务
      throw new TransactionException("Transaction not exist.");
    }

    ConnectionHolder conHolder = txObject.getConnectionHolder();
    if (conHolder.isOpen()) {// 还有后续事务,不提交
      return;
View Full Code Here

    try {
      JdbcTransactionContext txObject = (JdbcTransactionContext) context;
      JdbcUtils.commitTransaction(txObject.getConnectionHolder().getCurrentConnection());
    } catch (SQLException e) {
      throw new TransactionException("Commit transaction failed.", e);
    } catch (RuntimeException e) {
      throw new TransactionException("Commit transaction failed.", e);
    } finally {
      clean(context);//清除事务
    }
  }
View Full Code Here

    JdbcTransactionContext txObject = (JdbcTransactionContext) context;
    try {
      JdbcUtils.rollbackTransaction(txObject.getConnectionHolder().getCurrentConnection());
    } catch (SQLException e) {
      throw new TransactionException("Rollback transaction failed.", e);
    } catch (RuntimeException e) {
      throw new TransactionException("Rollback transaction failed.", e);
    } finally {
      txObject.setComplete(true);
      txObject.getConnectionHolder().setCurrentConnection(null);//清除链接
    }
  }
View Full Code Here

        LOGGER.debug("Acquired Connection [" + newCon + "] for JDBC transaction");
        conHolder = new ConnectionHolder(newCon);
        txObject.setConnectionHolder(conHolder);
        txObject.setTxDataSource(dataSource);
      } else if (conHolder == null) {
        throw new TransactionException("lazy begin must has a connection holder");
      }
     
      con = conHolder.getCurrentConnection();
      JdbcUtils.prepareConnectionForTransaction(con, definition);
 
    } catch (Exception ex) {
      JdbcUtils.releaseConnection(con);
      throw new TransactionException("Could not open JDBC Connection for transaction", ex);
    }
  }
View Full Code Here

TOP

Related Classes of com.skyline.energy.exception.TransactionException

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.