Example usage for org.apache.commons.dbcp2.datasources SharedPoolDataSource setDefaultMaxWaitMillis

List of usage examples for org.apache.commons.dbcp2.datasources SharedPoolDataSource setDefaultMaxWaitMillis

Introduction

In this page you can find the example usage for org.apache.commons.dbcp2.datasources SharedPoolDataSource setDefaultMaxWaitMillis.

Prototype

public void setDefaultMaxWaitMillis(long maxWaitMillis) 

Source Link

Document

Sets the default value for GenericKeyedObjectPoolConfig#getMaxWaitMillis() for each per user pool.

Usage

From source file:org.lightmare.jpa.datasource.dbcp.InitDBCP.java

@Override
public DataSource initializeDataSource() throws IOException {

    String jndiName = Initializer.getJndiName(properties);

    DriverAdapterCPDS dacp = new DriverAdapterCPDS();

    try {// w  w w .  j  a  v a  2 s.  c  o  m
        dacp.setDriver(driver);
    } catch (ClassNotFoundException ex) {
        throw new IOException(ex);
    }
    dacp.setUrl(url);
    dacp.setUser(user);
    dacp.setPassword(password);

    SharedPoolDataSource dataSource = new SharedPoolDataSource();
    dataSource.setDataSourceName(jndiName);
    dataSource.setDefaultAutoCommit(Boolean.FALSE);
    dataSource.setDefaultReadOnly(Boolean.FALSE);
    dataSource.setDefaultTransactionIsolation(DEFAULT_TRANSACTION_ISOLATION);
    dataSource.setLoginTimeout(PoolConfig.asInt(properties, PoolConfig.Defaults.MAX_IDLE_TIMEOUT));
    dataSource.setDefaultMaxTotal(PoolConfig.asInt(properties, PoolConfig.Defaults.MAX_POOL_SIZE));
    dataSource.setDefaultMaxIdle(PoolConfig.asInt(properties, PoolConfig.Defaults.MAX_IDLE_TIMEOUT));
    dataSource.setDefaultMaxWaitMillis(PoolConfig.asInt(properties, PoolConfig.Defaults.CHECK_OUT_TIMEOUT));

    return dataSource;
}