Example usage for org.apache.commons.pool2.impl GenericKeyedObjectPoolConfig DEFAULT_MAX_IDLE_PER_KEY

List of usage examples for org.apache.commons.pool2.impl GenericKeyedObjectPoolConfig DEFAULT_MAX_IDLE_PER_KEY

Introduction

In this page you can find the example usage for org.apache.commons.pool2.impl GenericKeyedObjectPoolConfig DEFAULT_MAX_IDLE_PER_KEY.

Prototype

int DEFAULT_MAX_IDLE_PER_KEY

To view the source code for org.apache.commons.pool2.impl GenericKeyedObjectPoolConfig DEFAULT_MAX_IDLE_PER_KEY.

Click Source Link

Document

The default value for the maxIdlePerKey configuration attribute.

Usage

From source file:de.micromata.genome.util.runtime.LocalSettingsEnv.java

/**
 * Parses the ds.//from w  w w.j a  v  a 2  s .c  om
 */
protected void parseDs() {
    // db.ds.rogerdb.name=RogersOracle
    // db.ds.rogerdb.drivername=oracle.jdbc.driver.OracleDriver
    // db.ds.rogerdb.url=jdbc:oracle:thin:@localhost:1521:rogdb
    // db.ds.rogerdb.username=genome
    // db.ds.rogerdb.password=genome
    List<String> dse = localSettings.getKeysPrefixWithInfix("db.ds", "name");
    for (String dsn : dse) {
        String key = dsn + ".name";
        String name = localSettings.get(key);
        if (StringUtils.isBlank(name) == true) {
            log.error("Name in local-settings is not defined with key: " + key);
            continue;
        }
        key = dsn + ".drivername";
        String driverName = localSettings.get(key);
        if (StringUtils.isBlank(name) == true) {
            log.error("drivername in local-settings is not defined with key: " + key);
            continue;
        }
        key = dsn + ".url";
        String url = localSettings.get(key);
        if (StringUtils.isBlank(name) == true) {
            log.error("url in local-settings is not defined with key: " + key);
            continue;
        }
        key = dsn + ".username";
        String userName = localSettings.get(key);
        key = dsn + ".password";
        String password = localSettings.get(key);
        BasicDataSource bd = dataSourceSuplier.get();

        bd.setDriverClassName(driverName);
        bd.setUrl(url);
        bd.setUsername(userName);
        bd.setPassword(password);
        bd.setMaxTotal(localSettings.getIntValue(dsn + ".maxActive",
                GenericKeyedObjectPoolConfig.DEFAULT_MAX_TOTAL_PER_KEY));
        bd.setMaxIdle(localSettings.getIntValue(dsn + ".maxIdle",
                GenericKeyedObjectPoolConfig.DEFAULT_MAX_IDLE_PER_KEY));
        bd.setMinIdle(localSettings.getIntValue(dsn + ".minIdle",
                GenericKeyedObjectPoolConfig.DEFAULT_MIN_IDLE_PER_KEY));
        bd.setMaxWaitMillis(localSettings.getLongValue(dsn + ".maxWait",
                GenericKeyedObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS));
        bd.setInitialSize(localSettings.getIntValue(dsn + ".intialSize", 0));
        bd.setDefaultCatalog(localSettings.get(dsn + ".defaultCatalog", null));
        bd.setDefaultAutoCommit(localSettings.getBooleanValue(dsn + ".defaultAutoCommit", true));
        bd.setValidationQuery(localSettings.get(dsn + ".validationQuery", null));
        bd.setValidationQueryTimeout(localSettings.getIntValue(dsn + ".validationQueryTimeout", -1));
        dataSources.put(name, bd);
    }
}