Example usage for java.sql Connection TRANSACTION_REPEATABLE_READ

List of usage examples for java.sql Connection TRANSACTION_REPEATABLE_READ

Introduction

In this page you can find the example usage for java.sql Connection TRANSACTION_REPEATABLE_READ.

Prototype

int TRANSACTION_REPEATABLE_READ

To view the source code for java.sql Connection TRANSACTION_REPEATABLE_READ.

Click Source Link

Document

A constant indicating that dirty reads and non-repeatable reads are prevented; phantom reads can occur.

Usage

From source file:com.oltpbenchmark.WorkloadConfiguration.java

public void setIsolationMode(String mode) {
    if (mode.equals("TRANSACTION_SERIALIZABLE"))
        this.isolationMode = Connection.TRANSACTION_SERIALIZABLE;
    else if (mode.equals("TRANSACTION_READ_COMMITTED"))
        this.isolationMode = Connection.TRANSACTION_READ_COMMITTED;
    else if (mode.equals("TRANSACTION_REPEATABLE_READ"))
        this.isolationMode = Connection.TRANSACTION_REPEATABLE_READ;
    else if (mode.equals("TRANSACTION_READ_UNCOMMITTED"))
        this.isolationMode = Connection.TRANSACTION_READ_UNCOMMITTED;
    else if (!mode.isEmpty())
        System.out.println("Indefined isolation mode, set to default [TRANSACTION_SERIALIZABLE]");
}

From source file:com.feedzai.commons.sql.abstraction.engine.impl.OracleEngine.java

/**
 * Overrides {@link com.feedzai.commons.sql.abstraction.engine.AbstractDatabaseEngine#setTransactionIsolation()} This is because
 * Oracle does not support READ_UNCOMMITTED e REPEATABLE_READ.
 *
 * @throws SQLException If a database access error occurs.
 *//*from   w w w . j  a v a2 s  . c o m*/
@Override
protected void setTransactionIsolation() throws SQLException {
    int isolation = properties.getIsolationLevel();

    if (isolation == Connection.TRANSACTION_READ_UNCOMMITTED) {
        isolation = Connection.TRANSACTION_READ_COMMITTED;
    }

    if (isolation == Connection.TRANSACTION_REPEATABLE_READ) {
        isolation = Connection.TRANSACTION_SERIALIZABLE;
    }

    conn.setTransactionIsolation(isolation);
}

From source file:com.glaf.core.jdbc.connection.TomcatJdbcConnectionProvider.java

protected void parsePoolProperties(PoolConfiguration poolProperties, Properties properties) {

    String value = null;/*from  w w  w.j  a  va 2 s  .c o  m*/

    value = properties.getProperty(ConnectionConstants.PROP_DEFAULTAUTOCOMMIT);
    if (value != null) {
        poolProperties.setDefaultAutoCommit(Boolean.valueOf(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_DEFAULTREADONLY);
    if (value != null) {
        poolProperties.setDefaultReadOnly(Boolean.valueOf(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_DEFAULTTRANSACTIONISOLATION);
    if (value != null) {
        int level = ConnectionConstants.UNKNOWN_TRANSACTIONISOLATION;
        if ("NONE".equalsIgnoreCase(value)) {
            level = Connection.TRANSACTION_NONE;
        } else if ("READ_COMMITTED".equalsIgnoreCase(value)) {
            level = Connection.TRANSACTION_READ_COMMITTED;
        } else if ("READ_UNCOMMITTED".equalsIgnoreCase(value)) {
            level = Connection.TRANSACTION_READ_UNCOMMITTED;
        } else if ("REPEATABLE_READ".equalsIgnoreCase(value)) {
            level = Connection.TRANSACTION_REPEATABLE_READ;
        } else if ("SERIALIZABLE".equalsIgnoreCase(value)) {
            level = Connection.TRANSACTION_SERIALIZABLE;
        } else {
            try {
                level = Integer.parseInt(value);
            } catch (NumberFormatException e) {
                System.err.println("Could not parse defaultTransactionIsolation: " + value);
                System.err.println("WARNING: defaultTransactionIsolation not set");
                System.err.println("using default value of database driver");
                level = ConnectionConstants.UNKNOWN_TRANSACTIONISOLATION;
            }
        }
        poolProperties.setDefaultTransactionIsolation(level);
    }

    value = properties.getProperty(ConnectionConstants.PROP_DEFAULTCATALOG);
    if (value != null) {
        poolProperties.setDefaultCatalog(value);
    }

    value = properties.getProperty(ConnectionConstants.PROP_MAXACTIVE);
    if (value != null && StringUtils.isNumeric(value)) {
        poolProperties.setMaxActive(Integer.parseInt(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_MAXIDLE);
    if (value != null && StringUtils.isNumeric(value)) {
        poolProperties.setMaxIdle(Integer.parseInt(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_MINIDLE);
    if (value != null && StringUtils.isNumeric(value)) {
        poolProperties.setMinIdle(Integer.parseInt(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_INITIALSIZE);
    if (value != null && StringUtils.isNumeric(value)) {
        poolProperties.setInitialSize(Integer.parseInt(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_MAXWAIT);
    if (value != null && StringUtils.isNumeric(value)) {
        poolProperties.setMaxWait(Integer.parseInt(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_TESTONBORROW);
    if (value != null) {
        poolProperties.setTestOnBorrow(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(ConnectionConstants.PROP_TESTONRETURN);
    if (value != null) {
        poolProperties.setTestOnReturn(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(ConnectionConstants.PROP_TESTONCONNECT);
    if (value != null) {
        poolProperties.setTestOnConnect(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(ConnectionConstants.PROP_TIMEBETWEENEVICTIONRUNSMILLIS);
    if (value != null && StringUtils.isNumeric(value)) {
        poolProperties.setTimeBetweenEvictionRunsMillis(Integer.parseInt(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_NUMTESTSPEREVICTIONRUN);
    if (value != null && StringUtils.isNumeric(value)) {
        poolProperties.setNumTestsPerEvictionRun(Integer.parseInt(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_MINEVICTABLEIDLETIMEMILLIS);
    if (value != null && StringUtils.isNumeric(value)) {
        poolProperties.setMinEvictableIdleTimeMillis(Integer.parseInt(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_TESTWHILEIDLE);
    if (value != null) {
        poolProperties.setTestWhileIdle(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(ConnectionConstants.PROP_VALIDATOR_CLASS_NAME);
    if (value != null) {
        poolProperties.setValidatorClassName(value);
    }

    value = properties.getProperty(ConnectionConstants.PROP_VALIDATIONINTERVAL);
    if (value != null && StringUtils.isNumeric(value)) {
        poolProperties.setValidationInterval(Long.parseLong(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWED);
    if (value != null) {
        poolProperties.setAccessToUnderlyingConnectionAllowed(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(ConnectionConstants.PROP_REMOVEABANDONED);
    if (value != null) {
        poolProperties.setRemoveAbandoned(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(ConnectionConstants.PROP_REMOVEABANDONEDTIMEOUT);
    if (value != null && StringUtils.isNumeric(value)) {
        poolProperties.setRemoveAbandonedTimeout(Integer.parseInt(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_LOGABANDONED);
    if (value != null) {
        poolProperties.setLogAbandoned(Boolean.valueOf(value).booleanValue());
    }

    if (poolProperties.getUsername() != null) {
        poolProperties.getDbProperties().setProperty("user", poolProperties.getUsername());
    }
    if (poolProperties.getPassword() != null) {
        poolProperties.getDbProperties().setProperty("password", poolProperties.getPassword());
    }

    value = properties.getProperty(ConnectionConstants.PROP_INITSQL);
    if (value != null) {
        poolProperties.setInitSQL(value);
    }

    value = properties.getProperty(ConnectionConstants.PROP_INTERCEPTORS);
    if (value != null) {
        poolProperties.setJdbcInterceptors(value);
    }

    value = properties.getProperty(ConnectionConstants.PROP_JMX_ENABLED);
    if (value != null) {
        poolProperties.setJmxEnabled(Boolean.parseBoolean(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_FAIR_QUEUE);
    if (value != null) {
        poolProperties.setFairQueue(Boolean.parseBoolean(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_USE_EQUALS);
    if (value != null) {
        poolProperties.setUseEquals(Boolean.parseBoolean(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_ABANDONWHENPERCENTAGEFULL);
    if (value != null && StringUtils.isNumeric(value)) {
        poolProperties.setAbandonWhenPercentageFull(Integer.parseInt(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_MAXAGE);
    if (value != null && StringUtils.isNumeric(value)) {
        poolProperties.setMaxAge(Long.parseLong(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_USE_CON_LOCK);
    if (value != null) {
        poolProperties.setUseLock(Boolean.parseBoolean(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_SUSPECT_TIMEOUT);
    if (value != null && StringUtils.isNumeric(value)) {
        poolProperties.setSuspectTimeout(Integer.parseInt(value));
    }

    value = properties.getProperty(ConnectionConstants.PROP_ALTERNATE_USERNAME_ALLOWED);
    if (value != null) {
        poolProperties.setAlternateUsernameAllowed(Boolean.parseBoolean(value));
    }

}

From source file:com.feedzai.commons.sql.abstraction.engine.configuration.PdbProperties.java

/**
 * Gets the isolation level.//from  w  w  w . ja v a 2s. c o  m
 *
 * @return The isolation level.
 */
public int getIsolationLevel() {
    final Optional<IsolationLevel> e = Enums.getIfPresent(IsolationLevel.class,
            getProperty(ISOLATION_LEVEL).toUpperCase());

    if (!e.isPresent()) {
        throw new DatabaseEngineRuntimeException(ISOLATION_LEVEL + " must be set and be one of the following: "
                + EnumSet.allOf(IsolationLevel.class));
    }

    switch (e.get()) {
    case READ_UNCOMMITTED:
        return Connection.TRANSACTION_READ_UNCOMMITTED;
    case READ_COMMITTED:
        return Connection.TRANSACTION_READ_COMMITTED;
    case REPEATABLE_READ:
        return Connection.TRANSACTION_REPEATABLE_READ;
    case SERIALIZABLE:
        return Connection.TRANSACTION_SERIALIZABLE;
    default:
        // Never happens.
        throw new DatabaseEngineRuntimeException("New isolation level?!" + e.get());
    }
}

From source file:io.vitess.jdbc.VitessMySQLDatabaseMetadata.java

public boolean supportsTransactionIsolationLevel(int level) throws SQLException {
    switch (level) {
    case Connection.TRANSACTION_READ_COMMITTED:
    case Connection.TRANSACTION_READ_UNCOMMITTED:
    case Connection.TRANSACTION_REPEATABLE_READ:
    case Connection.TRANSACTION_SERIALIZABLE:
        return true;

    default:// w ww .  ja  v a2 s .  c o  m
        return false;
    }
}

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

/**
 * Creates and configures a {@link BasicDataSource} instance based on the
 * given properties.// w  ww .  jav  a 2  s  .  c o  m
 *
 * @param properties the datasource configuration properties
 * @throws Exception if an error occurs creating the data source
 */
public static BasicDataSource createDataSource(Properties properties) throws Exception {
    BasicDataSource dataSource = new BasicDataSource();
    String value = null;

    value = properties.getProperty(PROP_DEFAULTAUTOCOMMIT);
    if (value != null) {
        dataSource.setDefaultAutoCommit(Boolean.valueOf(value));
    }

    value = properties.getProperty(PROP_DEFAULTREADONLY);
    if (value != null) {
        dataSource.setDefaultReadOnly(Boolean.valueOf(value));
    }

    value = properties.getProperty(PROP_DEFAULTTRANSACTIONISOLATION);
    if (value != null) {
        int level = PoolableConnectionFactory.UNKNOWN_TRANSACTIONISOLATION;
        if ("NONE".equalsIgnoreCase(value)) {
            level = Connection.TRANSACTION_NONE;
        } else if ("READ_COMMITTED".equalsIgnoreCase(value)) {
            level = Connection.TRANSACTION_READ_COMMITTED;
        } else if ("READ_UNCOMMITTED".equalsIgnoreCase(value)) {
            level = Connection.TRANSACTION_READ_UNCOMMITTED;
        } else if ("REPEATABLE_READ".equalsIgnoreCase(value)) {
            level = Connection.TRANSACTION_REPEATABLE_READ;
        } else if ("SERIALIZABLE".equalsIgnoreCase(value)) {
            level = Connection.TRANSACTION_SERIALIZABLE;
        } else {
            try {
                level = Integer.parseInt(value);
            } catch (NumberFormatException e) {
                System.err.println("Could not parse defaultTransactionIsolation: " + value);
                System.err.println("WARNING: defaultTransactionIsolation not set");
                System.err.println("using default value of database driver");
                level = PoolableConnectionFactory.UNKNOWN_TRANSACTIONISOLATION;
            }
        }
        dataSource.setDefaultTransactionIsolation(level);
    }

    value = properties.getProperty(PROP_DEFAULTCATALOG);
    if (value != null) {
        dataSource.setDefaultCatalog(value);
    }

    value = properties.getProperty(PROP_CACHESTATE);
    if (value != null) {
        dataSource.setCacheState(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_DRIVERCLASSNAME);
    if (value != null) {
        dataSource.setDriverClassName(value);
    }

    value = properties.getProperty(PROP_LIFO);
    if (value != null) {
        dataSource.setLifo(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_MAXTOTAL);
    if (value != null) {
        dataSource.setMaxTotal(Integer.parseInt(value));
    }

    value = properties.getProperty(PROP_MAXIDLE);
    if (value != null) {
        dataSource.setMaxIdle(Integer.parseInt(value));
    }

    value = properties.getProperty(PROP_MINIDLE);
    if (value != null) {
        dataSource.setMinIdle(Integer.parseInt(value));
    }

    value = properties.getProperty(PROP_INITIALSIZE);
    if (value != null) {
        dataSource.setInitialSize(Integer.parseInt(value));
    }

    value = properties.getProperty(PROP_MAXWAITMILLIS);
    if (value != null) {
        dataSource.setMaxWaitMillis(Long.parseLong(value));
    }

    value = properties.getProperty(PROP_TESTONCREATE);
    if (value != null) {
        dataSource.setTestOnCreate(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_TESTONBORROW);
    if (value != null) {
        dataSource.setTestOnBorrow(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_TESTONRETURN);
    if (value != null) {
        dataSource.setTestOnReturn(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_TIMEBETWEENEVICTIONRUNSMILLIS);
    if (value != null) {
        dataSource.setTimeBetweenEvictionRunsMillis(Long.parseLong(value));
    }

    value = properties.getProperty(PROP_NUMTESTSPEREVICTIONRUN);
    if (value != null) {
        dataSource.setNumTestsPerEvictionRun(Integer.parseInt(value));
    }

    value = properties.getProperty(PROP_MINEVICTABLEIDLETIMEMILLIS);
    if (value != null) {
        dataSource.setMinEvictableIdleTimeMillis(Long.parseLong(value));
    }

    value = properties.getProperty(PROP_SOFTMINEVICTABLEIDLETIMEMILLIS);
    if (value != null) {
        dataSource.setSoftMinEvictableIdleTimeMillis(Long.parseLong(value));
    }

    value = properties.getProperty(PROP_EVICTIONPOLICYCLASSNAME);
    if (value != null) {
        dataSource.setEvictionPolicyClassName(value);
    }

    value = properties.getProperty(PROP_TESTWHILEIDLE);
    if (value != null) {
        dataSource.setTestWhileIdle(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_PASSWORD);
    if (value != null) {
        dataSource.setPassword(value);
    }

    value = properties.getProperty(PROP_URL);
    if (value != null) {
        dataSource.setUrl(value);
    }

    value = properties.getProperty(PROP_USERNAME);
    if (value != null) {
        dataSource.setUsername(value);
    }

    value = properties.getProperty(PROP_VALIDATIONQUERY);
    if (value != null) {
        dataSource.setValidationQuery(value);
    }

    value = properties.getProperty(PROP_VALIDATIONQUERY_TIMEOUT);
    if (value != null) {
        dataSource.setValidationQueryTimeout(Integer.parseInt(value));
    }

    value = properties.getProperty(PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWED);
    if (value != null) {
        dataSource.setAccessToUnderlyingConnectionAllowed(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_REMOVEABANDONEDONBORROW);
    if (value != null) {
        dataSource.setRemoveAbandonedOnBorrow(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_REMOVEABANDONEDONMAINTENANCE);
    if (value != null) {
        dataSource.setRemoveAbandonedOnMaintenance(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_REMOVEABANDONEDTIMEOUT);
    if (value != null) {
        dataSource.setRemoveAbandonedTimeout(Integer.parseInt(value));
    }

    value = properties.getProperty(PROP_LOGABANDONED);
    if (value != null) {
        dataSource.setLogAbandoned(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_POOLPREPAREDSTATEMENTS);
    if (value != null) {
        dataSource.setPoolPreparedStatements(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_MAXOPENPREPAREDSTATEMENTS);
    if (value != null) {
        dataSource.setMaxOpenPreparedStatements(Integer.parseInt(value));
    }

    value = properties.getProperty(PROP_CONNECTIONINITSQLS); //?ConnectionSQL?
    if (value != null) {
        dataSource.setConnectionInitSqls(parseList(value, ';'));
    }

    value = properties.getProperty(PROP_CONNECTIONPROPERTIES);
    if (value != null) {
        Properties p = getProperties(value);
        Enumeration<?> e = p.propertyNames();
        while (e.hasMoreElements()) {
            String propertyName = (String) e.nextElement();
            dataSource.addConnectionProperty(propertyName, p.getProperty(propertyName));
        }
    }

    value = properties.getProperty(PROP_MAXCONNLIFETIMEMILLIS);
    if (value != null) {
        dataSource.setMaxConnLifetimeMillis(Long.parseLong(value));
    }

    value = properties.getProperty(PROP_LOGEXPIREDCONNECTIONS);
    if (value != null) {
        dataSource.setLogExpiredConnections(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_JMX_NAME);
    if (value != null) {
        dataSource.setJmxName(value);
    }

    value = properties.getProperty(PROP_ENABLE_AUTOCOMMIT_ON_RETURN);
    if (value != null) {
        dataSource.setEnableAutoCommitOnReturn(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_ROLLBACK_ON_RETURN);
    if (value != null) {
        dataSource.setRollbackOnReturn(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_DEFAULT_QUERYTIMEOUT);
    if (value != null) {
        dataSource.setDefaultQueryTimeout(Integer.valueOf(value));
    }

    value = properties.getProperty(PROP_FASTFAIL_VALIDATION);
    if (value != null) {
        dataSource.setFastFailValidation(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_DISCONNECTION_SQL_CODES);
    if (value != null) {
        dataSource.setDisconnectionSqlCodes(parseList(value, ','));
    }

    // DBCP-215
    // Trick to make sure that initialSize connections are created
    if (dataSource.getInitialSize() > 0) {
        dataSource.getLogWriter();
    }

    // Return the configured DataSource instance
    return dataSource;
}

From source file:com.frameworkset.commons.dbcp2.BasicDataSourceFactory.java

/**
 * Creates and configures a {@link BasicDataSource} instance based on the
 * given properties.//from w  w  w  .j av a 2 s  .  c o  m
 *
 * @param properties the datasource configuration properties
 * @throws Exception if an error occurs creating the data source
 */
public static BasicDataSource createDataSource(Properties properties) throws Exception {
    BasicDataSource dataSource = new BasicDataSource();
    String value = null;

    value = properties.getProperty(PROP_DEFAULTAUTOCOMMIT);
    if (value != null) {
        dataSource.setDefaultAutoCommit(Boolean.valueOf(value));
    }

    value = properties.getProperty(PROP_DEFAULTREADONLY);
    if (value != null) {
        dataSource.setDefaultReadOnly(Boolean.valueOf(value));
    }

    value = properties.getProperty(PROP_DEFAULTTRANSACTIONISOLATION);
    if (value != null) {
        int level = PoolableConnectionFactory.UNKNOWN_TRANSACTIONISOLATION;
        if ("NONE".equalsIgnoreCase(value)) {
            level = Connection.TRANSACTION_NONE;
        } else if ("READ_COMMITTED".equalsIgnoreCase(value)) {
            level = Connection.TRANSACTION_READ_COMMITTED;
        } else if ("READ_UNCOMMITTED".equalsIgnoreCase(value)) {
            level = Connection.TRANSACTION_READ_UNCOMMITTED;
        } else if ("REPEATABLE_READ".equalsIgnoreCase(value)) {
            level = Connection.TRANSACTION_REPEATABLE_READ;
        } else if ("SERIALIZABLE".equalsIgnoreCase(value)) {
            level = Connection.TRANSACTION_SERIALIZABLE;
        } else {
            try {
                level = Integer.parseInt(value);
            } catch (NumberFormatException e) {
                System.err.println("Could not parse defaultTransactionIsolation: " + value);
                System.err.println("WARNING: defaultTransactionIsolation not set");
                System.err.println("using default value of database driver");
                level = PoolableConnectionFactory.UNKNOWN_TRANSACTIONISOLATION;
            }
        }
        dataSource.setDefaultTransactionIsolation(level);
    }

    value = properties.getProperty(PROP_DEFAULTCATALOG);
    if (value != null) {
        dataSource.setDefaultCatalog(value);
    }

    value = properties.getProperty(PROP_CACHESTATE);
    if (value != null) {
        dataSource.setCacheState(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_DRIVERCLASSNAME);
    if (value != null) {
        dataSource.setDriverClassName(value);
    }

    value = properties.getProperty(PROP_LIFO);
    if (value != null) {
        dataSource.setLifo(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_MAXTOTAL);
    if (value != null) {
        dataSource.setMaxTotal(Integer.parseInt(value));
    }

    value = properties.getProperty(PROP_MAXIDLE);
    if (value != null) {
        dataSource.setMaxIdle(Integer.parseInt(value));
    }

    value = properties.getProperty(PROP_MINIDLE);
    if (value != null) {
        dataSource.setMinIdle(Integer.parseInt(value));
    }

    value = properties.getProperty(PROP_INITIALSIZE);
    if (value != null) {
        dataSource.setInitialSize(Integer.parseInt(value));
    }

    value = properties.getProperty(PROP_MAXWAITMILLIS);
    if (value != null) {
        dataSource.setMaxWaitMillis(Long.parseLong(value));
    }

    value = properties.getProperty(PROP_TESTONCREATE);
    if (value != null) {
        dataSource.setTestOnCreate(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_TESTONBORROW);
    if (value != null) {
        dataSource.setTestOnBorrow(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_TESTONRETURN);
    if (value != null) {
        dataSource.setTestOnReturn(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_TIMEBETWEENEVICTIONRUNSMILLIS);
    if (value != null) {
        dataSource.setTimeBetweenEvictionRunsMillis(Long.parseLong(value));
    }

    value = properties.getProperty(PROP_NUMTESTSPEREVICTIONRUN);
    if (value != null) {
        dataSource.setNumTestsPerEvictionRun(Integer.parseInt(value));
    }

    value = properties.getProperty(PROP_MINEVICTABLEIDLETIMEMILLIS);
    if (value != null) {
        dataSource.setMinEvictableIdleTimeMillis(Long.parseLong(value));
    }

    value = properties.getProperty(PROP_SOFTMINEVICTABLEIDLETIMEMILLIS);
    if (value != null) {
        dataSource.setSoftMinEvictableIdleTimeMillis(Long.parseLong(value));
    }

    value = properties.getProperty(PROP_EVICTIONPOLICYCLASSNAME);
    if (value != null) {
        dataSource.setEvictionPolicyClassName(value);
    }

    value = properties.getProperty(PROP_TESTWHILEIDLE);
    if (value != null) {
        dataSource.setTestWhileIdle(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_PASSWORD);
    if (value != null) {
        dataSource.setPassword(value);
    }

    value = properties.getProperty(PROP_URL);
    if (value != null) {
        dataSource.setUrl(value);
    }

    value = properties.getProperty(PROP_USERNAME);
    if (value != null) {
        dataSource.setUsername(value);
    }

    value = properties.getProperty(PROP_VALIDATIONQUERY);
    if (value != null) {
        dataSource.setValidationQuery(value);
    }

    value = properties.getProperty(PROP_VALIDATIONQUERY_TIMEOUT);
    if (value != null) {
        dataSource.setValidationQueryTimeout(Integer.parseInt(value));
    }

    value = properties.getProperty(PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWED);
    if (value != null) {
        dataSource.setAccessToUnderlyingConnectionAllowed(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_REMOVEABANDONEDONBORROW);
    if (value != null) {
        dataSource.setRemoveAbandonedOnBorrow(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_REMOVEABANDONEDONMAINTENANCE);
    if (value != null) {
        dataSource.setRemoveAbandonedOnMaintenance(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_REMOVEABANDONEDTIMEOUT);
    if (value != null) {
        dataSource.setRemoveAbandonedTimeout(Integer.parseInt(value));
    }

    value = properties.getProperty(PROP_LOGABANDONED);
    if (value != null) {
        dataSource.setLogAbandoned(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_POOLPREPAREDSTATEMENTS);
    if (value != null) {
        dataSource.setPoolPreparedStatements(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_MAXOPENPREPAREDSTATEMENTS);
    if (value != null) {
        dataSource.setMaxOpenPreparedStatements(Integer.parseInt(value));
    }

    value = properties.getProperty(PROP_CONNECTIONINITSQLS);
    if (value != null) {
        dataSource.setConnectionInitSqls(parseList(value, ';'));
    }

    value = properties.getProperty(PROP_CONNECTIONPROPERTIES);
    if (value != null) {
        Properties p = getProperties(value);
        Enumeration<?> e = p.propertyNames();
        while (e.hasMoreElements()) {
            String propertyName = (String) e.nextElement();
            dataSource.addConnectionProperty(propertyName, p.getProperty(propertyName));
        }
    }

    value = properties.getProperty(PROP_MAXCONNLIFETIMEMILLIS);
    if (value != null) {
        dataSource.setMaxConnLifetimeMillis(Long.parseLong(value));
    }

    value = properties.getProperty(PROP_LOGEXPIREDCONNECTIONS);
    if (value != null) {
        dataSource.setLogExpiredConnections(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_JMX_NAME);
    if (value != null) {
        dataSource.setJmxName(value);
    }

    value = properties.getProperty(PROP_ENABLE_AUTOCOMMIT_ON_RETURN);
    if (value != null) {
        dataSource.setEnableAutoCommitOnReturn(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_ROLLBACK_ON_RETURN);
    if (value != null) {
        dataSource.setRollbackOnReturn(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_DEFAULT_QUERYTIMEOUT);
    if (value != null) {
        dataSource.setDefaultQueryTimeout(Integer.valueOf(value));
    }

    value = properties.getProperty(PROP_FASTFAIL_VALIDATION);
    if (value != null) {
        dataSource.setFastFailValidation(Boolean.valueOf(value).booleanValue());
    }

    value = properties.getProperty(PROP_DISCONNECTION_SQL_CODES);
    if (value != null) {
        dataSource.setDisconnectionSqlCodes(parseList(value, ','));
    }

    // DBCP-215
    // Trick to make sure that initialSize connections are created
    if (dataSource.getInitialSize() > 0) {
        dataSource.getLogWriter();
    }

    // Return the configured DataSource instance
    return dataSource;
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstPgSql.CFAstPgSqlSchema.java

public CFAstPgSqlSchema(Connection argCnx) {
    super();/*from   ww  w .j  a  v a2s.  c  o  m*/
    cnx = argCnx;
    inTransaction = false;
    tableAsteriskConf = new CFAstPgSqlAsteriskConfTable(this);
    tableAuditAction = new CFAstPgSqlAuditActionTable(this);
    tableCluster = new CFAstPgSqlClusterTable(this);
    tableConfigurationFile = new CFAstPgSqlConfigurationFileTable(this);
    tableDomain = new CFAstPgSqlDomainTable(this);
    tableDomainBase = new CFAstPgSqlDomainBaseTable(this);
    tableExtConfigConf = new CFAstPgSqlExtConfigConfTable(this);
    tableExtensionsConf = new CFAstPgSqlExtensionsConfTable(this);
    tableHostNode = new CFAstPgSqlHostNodeTable(this);
    tableISOCountry = new CFAstPgSqlISOCountryTable(this);
    tableISOCountryCurrency = new CFAstPgSqlISOCountryCurrencyTable(this);
    tableISOCountryLanguage = new CFAstPgSqlISOCountryLanguageTable(this);
    tableISOCurrency = new CFAstPgSqlISOCurrencyTable(this);
    tableISOLanguage = new CFAstPgSqlISOLanguageTable(this);
    tableISOTimezone = new CFAstPgSqlISOTimezoneTable(this);
    tableMajorVersion = new CFAstPgSqlMajorVersionTable(this);
    tableMimeType = new CFAstPgSqlMimeTypeTable(this);
    tableMinorVersion = new CFAstPgSqlMinorVersionTable(this);
    tableProjectBase = new CFAstPgSqlProjectBaseTable(this);
    tableRealProject = new CFAstPgSqlRealProjectTable(this);
    tableSecApp = new CFAstPgSqlSecAppTable(this);
    tableSecForm = new CFAstPgSqlSecFormTable(this);
    tableSecGroup = new CFAstPgSqlSecGroupTable(this);
    tableSecGroupForm = new CFAstPgSqlSecGroupFormTable(this);
    tableSecGroupInclude = new CFAstPgSqlSecGroupIncludeTable(this);
    tableSecGroupMember = new CFAstPgSqlSecGroupMemberTable(this);
    tableSecSession = new CFAstPgSqlSecSessionTable(this);
    tableSecUser = new CFAstPgSqlSecUserTable(this);
    tableService = new CFAstPgSqlServiceTable(this);
    tableServiceType = new CFAstPgSqlServiceTypeTable(this);
    tableSipConf = new CFAstPgSqlSipConfTable(this);
    tableSubProject = new CFAstPgSqlSubProjectTable(this);
    tableTSecGroup = new CFAstPgSqlTSecGroupTable(this);
    tableTSecGroupInclude = new CFAstPgSqlTSecGroupIncludeTable(this);
    tableTSecGroupMember = new CFAstPgSqlTSecGroupMemberTable(this);
    tableTenant = new CFAstPgSqlTenantTable(this);
    tableTld = new CFAstPgSqlTldTable(this);
    tableTopDomain = new CFAstPgSqlTopDomainTable(this);
    tableTopProject = new CFAstPgSqlTopProjectTable(this);
    tableURLProtocol = new CFAstPgSqlURLProtocolTable(this);
    tableVersion = new CFAstPgSqlVersionTable(this);
    tableVoicemailConf = new CFAstPgSqlVoicemailConfTable(this);
    try {
        cnx.setAutoCommit(false);
        cnx.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
        cnx.rollback();
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "CFAstPgSqlSchema-constructor", e);
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstDb2LUW.CFAstDb2LUWSchema.java

public CFAstDb2LUWSchema(Connection argCnx) {
    super();//from  w w  w. j ava2  s.  c o m
    cnx = argCnx;
    inTransaction = false;
    tableAsteriskConf = new CFAstDb2LUWAsteriskConfTable(this);
    tableAuditAction = new CFAstDb2LUWAuditActionTable(this);
    tableCluster = new CFAstDb2LUWClusterTable(this);
    tableConfigurationFile = new CFAstDb2LUWConfigurationFileTable(this);
    tableDomain = new CFAstDb2LUWDomainTable(this);
    tableDomainBase = new CFAstDb2LUWDomainBaseTable(this);
    tableExtConfigConf = new CFAstDb2LUWExtConfigConfTable(this);
    tableExtensionsConf = new CFAstDb2LUWExtensionsConfTable(this);
    tableHostNode = new CFAstDb2LUWHostNodeTable(this);
    tableISOCountry = new CFAstDb2LUWISOCountryTable(this);
    tableISOCountryCurrency = new CFAstDb2LUWISOCountryCurrencyTable(this);
    tableISOCountryLanguage = new CFAstDb2LUWISOCountryLanguageTable(this);
    tableISOCurrency = new CFAstDb2LUWISOCurrencyTable(this);
    tableISOLanguage = new CFAstDb2LUWISOLanguageTable(this);
    tableISOTimezone = new CFAstDb2LUWISOTimezoneTable(this);
    tableMajorVersion = new CFAstDb2LUWMajorVersionTable(this);
    tableMimeType = new CFAstDb2LUWMimeTypeTable(this);
    tableMinorVersion = new CFAstDb2LUWMinorVersionTable(this);
    tableProjectBase = new CFAstDb2LUWProjectBaseTable(this);
    tableRealProject = new CFAstDb2LUWRealProjectTable(this);
    tableSecApp = new CFAstDb2LUWSecAppTable(this);
    tableSecForm = new CFAstDb2LUWSecFormTable(this);
    tableSecGroup = new CFAstDb2LUWSecGroupTable(this);
    tableSecGroupForm = new CFAstDb2LUWSecGroupFormTable(this);
    tableSecGroupInclude = new CFAstDb2LUWSecGroupIncludeTable(this);
    tableSecGroupMember = new CFAstDb2LUWSecGroupMemberTable(this);
    tableSecSession = new CFAstDb2LUWSecSessionTable(this);
    tableSecUser = new CFAstDb2LUWSecUserTable(this);
    tableService = new CFAstDb2LUWServiceTable(this);
    tableServiceType = new CFAstDb2LUWServiceTypeTable(this);
    tableSipConf = new CFAstDb2LUWSipConfTable(this);
    tableSubProject = new CFAstDb2LUWSubProjectTable(this);
    tableTSecGroup = new CFAstDb2LUWTSecGroupTable(this);
    tableTSecGroupInclude = new CFAstDb2LUWTSecGroupIncludeTable(this);
    tableTSecGroupMember = new CFAstDb2LUWTSecGroupMemberTable(this);
    tableTenant = new CFAstDb2LUWTenantTable(this);
    tableTld = new CFAstDb2LUWTldTable(this);
    tableTopDomain = new CFAstDb2LUWTopDomainTable(this);
    tableTopProject = new CFAstDb2LUWTopProjectTable(this);
    tableURLProtocol = new CFAstDb2LUWURLProtocolTable(this);
    tableVersion = new CFAstDb2LUWVersionTable(this);
    tableVoicemailConf = new CFAstDb2LUWVoicemailConfTable(this);
    try {
        cnx.setAutoCommit(false);
        cnx.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
        cnx.rollback();
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "CFAstDb2LUWSchema-constructor", e);
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstPgSql.CFAstPgSqlSchema.java

public CFAstPgSqlSchema(Connection argCnx) {
    super();// w  w  w. j a v  a 2s  . com
    cnx = argCnx;
    inTransaction = false;
    tableAsteriskConf = new CFAstPgSqlAsteriskConfTable(this);
    tableAuditAction = new CFAstPgSqlAuditActionTable(this);
    tableCluster = new CFAstPgSqlClusterTable(this);
    tableConfigurationFile = new CFAstPgSqlConfigurationFileTable(this);
    tableDomain = new CFAstPgSqlDomainTable(this);
    tableDomainBase = new CFAstPgSqlDomainBaseTable(this);
    tableExtConfigConf = new CFAstPgSqlExtConfigConfTable(this);
    tableExtensionsConf = new CFAstPgSqlExtensionsConfTable(this);
    tableHostNode = new CFAstPgSqlHostNodeTable(this);
    tableISOCountry = new CFAstPgSqlISOCountryTable(this);
    tableISOCountryCurrency = new CFAstPgSqlISOCountryCurrencyTable(this);
    tableISOCountryLanguage = new CFAstPgSqlISOCountryLanguageTable(this);
    tableISOCurrency = new CFAstPgSqlISOCurrencyTable(this);
    tableISOLanguage = new CFAstPgSqlISOLanguageTable(this);
    tableISOTimezone = new CFAstPgSqlISOTimezoneTable(this);
    tableMajorVersion = new CFAstPgSqlMajorVersionTable(this);
    tableMimeType = new CFAstPgSqlMimeTypeTable(this);
    tableMinorVersion = new CFAstPgSqlMinorVersionTable(this);
    tableProjectBase = new CFAstPgSqlProjectBaseTable(this);
    tableRealProject = new CFAstPgSqlRealProjectTable(this);
    tableSecApp = new CFAstPgSqlSecAppTable(this);
    tableSecDevice = new CFAstPgSqlSecDeviceTable(this);
    tableSecForm = new CFAstPgSqlSecFormTable(this);
    tableSecGroup = new CFAstPgSqlSecGroupTable(this);
    tableSecGroupForm = new CFAstPgSqlSecGroupFormTable(this);
    tableSecGroupInclude = new CFAstPgSqlSecGroupIncludeTable(this);
    tableSecGroupMember = new CFAstPgSqlSecGroupMemberTable(this);
    tableSecSession = new CFAstPgSqlSecSessionTable(this);
    tableSecUser = new CFAstPgSqlSecUserTable(this);
    tableService = new CFAstPgSqlServiceTable(this);
    tableServiceType = new CFAstPgSqlServiceTypeTable(this);
    tableSipConf = new CFAstPgSqlSipConfTable(this);
    tableSubProject = new CFAstPgSqlSubProjectTable(this);
    tableTSecGroup = new CFAstPgSqlTSecGroupTable(this);
    tableTSecGroupInclude = new CFAstPgSqlTSecGroupIncludeTable(this);
    tableTSecGroupMember = new CFAstPgSqlTSecGroupMemberTable(this);
    tableTenant = new CFAstPgSqlTenantTable(this);
    tableTld = new CFAstPgSqlTldTable(this);
    tableTopDomain = new CFAstPgSqlTopDomainTable(this);
    tableTopProject = new CFAstPgSqlTopProjectTable(this);
    tableURLProtocol = new CFAstPgSqlURLProtocolTable(this);
    tableVersion = new CFAstPgSqlVersionTable(this);
    tableVoicemailConf = new CFAstPgSqlVoicemailConfTable(this);
    try {
        cnx.setAutoCommit(false);
        cnx.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
        cnx.rollback();
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "CFAstPgSqlSchema-constructor", e);
    }
}