Example usage for org.apache.commons.dbcp PoolingConnection PoolingConnection

List of usage examples for org.apache.commons.dbcp PoolingConnection PoolingConnection

Introduction

In this page you can find the example usage for org.apache.commons.dbcp PoolingConnection PoolingConnection.

Prototype

public PoolingConnection(Connection c, KeyedObjectPool pool) 

Source Link

Document

Constructor.

Usage

From source file:org.nuxeo.runtime.datasource.PatchedPoolableManagedConnectionFactory.java

@Override
synchronized public Object makeObject() throws Exception {
    Connection conn = _connFactory.createConnection();
    if (conn == null) {
        throw new IllegalStateException("Connection factory returned null from createConnection");
    }/*w  w w  .j  a v a 2s  .  co  m*/
    initializeConnection(conn);
    if (null != _stmtPoolFactory) {
        KeyedObjectPool stmtpool = _stmtPoolFactory.createPool();
        conn = new PoolingConnection(conn, stmtpool);
        stmtpool.setFactory((PoolingConnection) conn);
    }
    // PATCH: use patched class
    return new PatchedPoolableManagedConnection(tr, conn, _pool, _config);
}

From source file:org.openconcerto.sql.model.SQLDataSource.java

@Override
protected void createPoolableConnectionFactory(ConnectionFactory driverConnectionFactory,
        @SuppressWarnings("rawtypes") KeyedObjectPoolFactory statementPoolFactory,
        AbandonedConfig configuration) throws SQLException {
    PoolableConnectionFactory connectionFactory = null;
    try {// ww  w.j a v a  2s .  c  om
        connectionFactory = new PoolableConnectionFactory(driverConnectionFactory, this.connectionPool,
                statementPoolFactory, this.validationQuery, this.validationQueryTimeout,
                this.connectionInitSqls, this.defaultReadOnly, this.defaultAutoCommit,
                this.defaultTransactionIsolation, this.defaultCatalog, configuration) {
            @Override
            public Object makeObject() throws Exception {
                Connection conn = this._connFactory.createConnection();
                if (conn == null) {
                    throw new IllegalStateException("Connection factory returned null from createConnection");
                }
                initializeConnection(conn);
                setTransactionIsolation(conn);
                if (null != this._stmtPoolFactory) {
                    @SuppressWarnings("rawtypes")
                    KeyedObjectPool stmtpool = this._stmtPoolFactory.createPool();
                    conn = new PoolingConnection(conn, stmtpool);
                    stmtpool.setFactory((PoolingConnection) conn);
                }
                return new TransactionPoolableConnection(conn, this._pool, this._config);
            }
        };
        validateConnectionFactory(connectionFactory);
    } catch (RuntimeException e) {
        throw e;
    } catch (SQLException e) {
        // only wrap if necessary (calling code can use SQLState)
        throw e;
    } catch (Exception e) {
        throw new SQLException("Cannot create PoolableConnectionFactory", e);
    }
}