Example usage for org.apache.commons.dbcp2 PoolingDataSource setAccessToUnderlyingConnectionAllowed

List of usage examples for org.apache.commons.dbcp2 PoolingDataSource setAccessToUnderlyingConnectionAllowed

Introduction

In this page you can find the example usage for org.apache.commons.dbcp2 PoolingDataSource setAccessToUnderlyingConnectionAllowed.

Prototype

public void setAccessToUnderlyingConnectionAllowed(boolean allow) 

Source Link

Document

Sets the value of the accessToUnderlyingConnectionAllowed property.

Usage

From source file:com.mirth.connect.donkey.server.data.jdbc.DBCPConnectionPool.java

public DBCPConnectionPool(String url, String username, String password, int maxConnections) {
    this.maxConnections = maxConnections;

    ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(url, username, password);
    PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,
            null);/*from   www.j  a va  2 s. com*/
    poolableConnectionFactory.setDefaultAutoCommit(false);

    GenericObjectPool<PoolableConnection> connectionPool = new GenericObjectPool<PoolableConnection>(
            poolableConnectionFactory);
    connectionPool.setMaxTotal(maxConnections);
    connectionPool.setMaxIdle(maxConnections);

    poolableConnectionFactory.setPool(connectionPool);

    PoolingDataSource<PoolableConnection> dataSource = new PoolingDataSource<PoolableConnection>(
            connectionPool);
    dataSource.setAccessToUnderlyingConnectionAllowed(true);

    this.dataSource = dataSource;
}

From source file:JDBCPool.dbcp.demo.sourcecode.BasicDataSource.java

/**
 * Creates the actual data source instance.  This method only exists so
 * that subclasses can replace the implementation class.
 *
 * @throws SQLException if unable to create a datasource instance
 *//*from w ww  .  ja va  2s  . c  om*/
protected DataSource createDataSourceInstance() throws SQLException {
    PoolingDataSource<PoolableConnection> pds = new PoolingDataSource<>(connectionPool);
    pds.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed());
    return pds;
}