Examples of ConnectionHolder


Examples of com.skyline.energy.dataaccess.jdbc.ConnectionHolder

      return dataSource.getConnection();
    }

    boolean shouldAddCount = false;
    Connection con = null;
    ConnectionHolder conHolder = txObject.getConnectionHolder();
    if (conHolder != null && conHolder.getCurrentConnection() != null) {// 已经存在事务
      // 判断是否可以使用上次的connection
      if (dataSource.equals(txObject.getTxDataSource())) {// 只对同一数据源进行事务处理
        con = conHolder.getCurrentConnection();
        shouldAddCount = true;
      } else {
        con = dataSource.getConnection();
      }
    } else { // 第一次开始事务
      JdbcTransactionManager txManager = (JdbcTransactionManager) txObject.getTxManager();
      if (distribute) {// 分布式数据源,只在第一此写操作时启动事务
        if (needBeginTransaction()) {
          beginNewTransaction(dataSource, txObject);
          con = txObject.getConnectionHolder().getCurrentConnection();
          shouldAddCount = true;
        } else {// 创建独立于事务之外的connection
          con = dataSource.getConnection();
        }
      } 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
    }

    if (shouldAddCount) {
      conHolder.addCounter();
    }

    return con;
  }
View Full Code Here

Examples of com.sun.gjc.spi.base.ConnectionHolder

     */
    public ConnectionHolder getConnection(Connection conObject,
                                          com.sun.gjc.spi.ManagedConnection mcObject,
                                          javax.resource.spi.ConnectionRequestInfo criObject,
                                          boolean statementWrapping) {
        ConnectionHolder connection = null;
        if (!initJDBC30Connection) {
            detectJDBC30Connection(conObject, mcObject);
        }
        if (statementWrapping) {
            connection = new ConnectionWrapper40(conObject, mcObject, criObject, jdbc30Connection);
View Full Code Here

Examples of com.sun.gjc.spi.base.ConnectionHolder

        if (connection == null) {
            String i18nMsg = localStrings.getString(
                    "jdbc.conn_handle_null");
            throw new ResourceException(i18nMsg);
        }
        ConnectionHolder ch = (ConnectionHolder) connection;

        com.sun.gjc.spi.ManagedConnection mc = ch.getManagedConnection();
        isClean = false;

        ch.associateConnection(actualConnection, this);
        /**
         * The expectation from the above method is that the connection holder
         * replaces the actual sql connection it holds with the sql connection
         * handle being passed in this method call. Also, it replaces the reference
         * to the ManagedConnection instance with this ManagedConnection instance.
         * Any previous statements and result sets also need to be removed.
         */


        ch.setActive(true);
        incrementCount();

        //mc will be null in case we are lazily associating
        if (mc != null) {
            mc.decrementCount();
View Full Code Here

Examples of com.sun.gjc.spi.base.ConnectionHolder

    protected void invalidateAllConnectionHandles() throws ResourceException {
        Set handles = connectionHandles.keySet();
        Iterator iter = handles.iterator();
        try {
            while (iter.hasNext()) {
                ConnectionHolder ch = (ConnectionHolder) iter.next();
                ch.invalidate();
            }
        } catch (java.util.NoSuchElementException nsee) {
            throw new ResourceException("Could not find the connection handle: " + nsee.getMessage());
        }
        connectionHandles.clear();
View Full Code Here

Examples of com.sun.gjc.spi.base.ConnectionHolder

     */
    public ConnectionHolder getConnection(Connection conObject,
                                          com.sun.gjc.spi.ManagedConnection mcObject,
                                          javax.resource.spi.ConnectionRequestInfo criObject,
                                          boolean statementWrapping) {
        ConnectionHolder connection = null;

        if (statementWrapping) {
            connection = new ConnectionWrapper30(conObject, mcObject, criObject);
        } else {
            connection = new ConnectionHolder30(conObject, mcObject, criObject);
View Full Code Here

Examples of net.hasor.db.datasource.local.ConnectionHolder

    //
    /**获取数据库连接(线程绑定的)*/
    protected TransactionObject doGetConnection(final JdbcTransactionStatus defStatus) throws SQLException {
        LocalDataSourceHelper localHelper = (LocalDataSourceHelper) DataSourceUtils.getDataSourceHelper();
        ConnectionSequence connSeq = localHelper.getConnectionSequence(this.getDataSource());
        ConnectionHolder holder = connSeq.currentHolder();
        if (holder.isOpen() == false || holder.hasTransaction() == false) {
            defStatus.markNewConnection();/*新事物,新连接*/
        }
        holder.requested();
        //下面两行代码用于保存当前Connection的隔离级别,并且设置新的隔离级别。
        int isolationLevel = holder.getConnection().getTransactionIsolation();
        Isolation level = null;
        if (defStatus.getIsolationLevel() != Isolation.DEFAULT) {
            holder.getConnection().setTransactionIsolation(defStatus.getIsolationLevel().ordinal());
            level = Isolation.valueOf(isolationLevel);
        }
        //
        return new TransactionObject(holder, level, this.getDataSource());
    }
View Full Code Here

Examples of org.objectweb.perseus.persistence.api.ConnectionHolder

  }

  public PName decodeAbstract(Object oid, Object context)
    throws PExceptionNaming, UnsupportedOperationException {
    Class clazz = null;
    ConnectionHolder conn = null;
    if (context != null) {
      if (!(context instanceof ConnectionHolder)) {
        clazz = (Class) context;
      } else {
        conn = (ConnectionHolder) context;
View Full Code Here

Examples of org.springframework.jdbc.datasource.ConnectionHolder

      pb.beginTransaction();

      // Register the OJB PersistenceBroker's JDBC Connection for the DataSource, if set.
      if (getDataSource() != null) {
        ConnectionHolder conHolder = new ConnectionHolder(con);
        if (definition.getTimeout() != TransactionDefinition.TIMEOUT_DEFAULT) {
          conHolder.setTimeoutInSeconds(definition.getTimeout());
        }
        if (logger.isDebugEnabled()) {
          logger.debug("Exposing OJB transaction as JDBC transaction [" + conHolder.getConnection() + "]");
        }
        TransactionSynchronizationManager.bindResource(getDataSource(), conHolder);
        txObject.setConnectionHolder(conHolder);
      }
View Full Code Here

Examples of org.springframework.jdbc.datasource.ConnectionHolder

  protected Object doSuspend(Object transaction) {
    PersistenceBrokerTransactionObject txObject = (PersistenceBrokerTransactionObject) transaction;
    txObject.setPersistenceBrokerHolder(null);
    PersistenceBrokerHolder pbHolder =
        (PersistenceBrokerHolder) TransactionSynchronizationManager.unbindResource(getPbKey());
    ConnectionHolder connectionHolder = null;
    if (getDataSource() != null) {
      connectionHolder = (ConnectionHolder) TransactionSynchronizationManager.unbindResource(getDataSource());
    }
    return new SuspendedResourcesHolder(pbHolder, connectionHolder);
  }
View Full Code Here

Examples of org.springframework.jdbc.datasource.ConnectionHolder

      }
      txObject.setEntityManagerHolder(emHolder, false);
    }

    if (getDataSource() != null) {
      ConnectionHolder conHolder = (ConnectionHolder)
          TransactionSynchronizationManager.getResource(getDataSource());
      txObject.setConnectionHolder(conHolder);
    }

    return txObject;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.