Example usage for org.apache.commons.dbcp BasicDataSource setPassword

List of usage examples for org.apache.commons.dbcp BasicDataSource setPassword

Introduction

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

Prototype

public synchronized void setPassword(String password) 

Source Link

Document

Sets the #password .

Note: this method currently has no effect once the pool has been initialized.

Usage

From source file:cn.vlabs.umt.common.datasource.DatabaseUtil.java

public DatabaseUtil(Config config) {
    BasicDataSource ds = new BasicDataSource();

    ds.setMaxActive(config.getInt("database.maxconn", 10));
    ds.setMaxIdle(config.getInt("database.maxidle", 3));
    ds.setMaxWait(100);//from ww  w  . ja va  2s. c  om

    ds.setUsername(config.getStringProp("database.username", null));
    ds.setPassword(config.getStringProp("database.password", null));
    ds.setDriverClassName(config.getStringProp("database.driver", null));
    ds.setUrl(config.getStringProp("database.conn-url", null));
    ds.setTimeBetweenEvictionRunsMillis(3600000);
    ds.setMinEvictableIdleTimeMillis(1200000);
    datasource = ds;
}

From source file:com.bt.aloha.sipstone.MaintenanceDao.java

public MaintenanceDao() throws Exception {
    InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("sip.properties");
    Properties dbProps = new Properties();
    dbProps.load(is);/*from   w w  w  .  j a  v  a2s .  c om*/
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName(dbProps.getProperty("database.driverClassName", "org.postgresql.Driver"));
    ds.setUrl(dbProps.getProperty("database.url", "jdbc:postgresql://localhost:5432/springring"));
    ds.setUsername(dbProps.getProperty("database.username", "springringuser"));
    ds.setPassword(dbProps.getProperty("database.password", "springringuser"));
    this.jdbcTemplate = new JdbcTemplate(ds);
}

From source file:de.iteratec.iteraplan.businesslogic.service.DataSourceServiceImpl.java

/** {@inheritDoc} */
public void initializeDBwithKey(String key) {
    DataSource dataSource = validateKey(key);
    if (dataSource == null) {
        // The key points to the MASTER data source. Nothing todo.
        return;// ww w . ja  v  a 2 s.  co  m
    }

    // Validation succeeded.
    // Add the data source only if it is not contained already.
    if (!routingDataSource.isKeyContained(key)) {

        // Create a basic data source.
        BasicDataSource ds = new CachableBasicDataSource();
        ds.setDriverClassName(dataSource.getDriver());
        ds.setUrl(dataSource.getUrl());
        ds.setUsername(dataSource.getUser());
        ds.setPassword(dataSource.getPassword());
        ds.setDefaultAutoCommit(false);

        String validationQuery = IteraplanProperties.getProperties()
                .getProperty(IteraplanProperties.DATABASE_VALIDATIONQUERY);
        ds.setValidationQuery(validationQuery);
        ds.setTestOnBorrow(true);
        // basicDataSource.setMaxActive(5);
        // basicDataSource.setMinIdle(1);

        routingDataSource.addCachableBasicDataSource(key, ds);
    }
}

From source file:com.dangdang.ddframe.job.lite.console.restful.EventTraceHistoryRestfulApi.java

private DataSource setUpEventTraceDataSource() {
    BasicDataSource result = new BasicDataSource();
    result.setDriverClassName(eventTraceDataSourceConfiguration.getDriver());
    result.setUrl(eventTraceDataSourceConfiguration.getUrl());
    result.setUsername(eventTraceDataSourceConfiguration.getUsername());
    result.setPassword(eventTraceDataSourceConfiguration.getPassword());
    return result;
}

From source file:com.dangdang.ddframe.job.statistics.rdb.StatisticRdbRepositoryTest.java

@Before
public void setup() throws SQLException {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(org.h2.Driver.class.getName());
    dataSource.setUrl("jdbc:h2:mem:");
    dataSource.setUsername("sa");
    dataSource.setPassword("");
    repository = new StatisticRdbRepository(dataSource);
}

From source file:calculus.backend.JpaConfig.java

@Bean
public DataSource dataSource() {

    loadProperties();/*from  w w  w.  j a  v  a  2s  .  c om*/

    BasicDataSource driver = new BasicDataSource();
    driver.setDriverClassName(this.driver);
    driver.setUrl(this.url);
    driver.setUsername(this.user);
    driver.setPassword(this.pass);
    driver.setMaxIdle(poolSize);
    driver.setMaxActive(poolSize);
    return driver;
}

From source file:de.langmi.spring.batch.examples.readers.support.CompositeCursorItemReaderTest.java

/**
 * Create a HSQLDB in-memory based datasource.
 *
 * @param url//from  ww w.jav  a  2s . c o  m
 * @return 
 */
private DataSource createDataSource(final String url) {
    // DataSource Setup with apache commons 
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
    dataSource.setUrl(url);
    dataSource.setUsername("sa");
    dataSource.setPassword("");

    return dataSource;
}

From source file:com.tedexis.commons.db.DBSinglePool.java

/**
 * Crea el pool de conexiones/*from w w  w .  j av a 2s .com*/
 *
 * @param configurationDB
 * @return
 * @throws ClassNotFoundException
 */
private BasicDataSource getBasicDataSource(ConfigurationDB configurationDB) throws ClassNotFoundException {
    BasicDataSource ds = null;
    if (dataSource == null) {

        ds = new BasicDataSource();

        Class.forName(configurationDB.driverClass);

        ds.setUrl(configurationDB.url);
        ds.setDriverClassName(configurationDB.driverClass);
        ds.setUsername(configurationDB.user);
        ds.setPassword(configurationDB.password);
        ds.setInitialSize(configurationDB.poolSize);
        ds.setMaxActive(configurationDB.poolMaxAct);
        ds.setMaxIdle(configurationDB.poolMaxIdle);
        ds.setMaxWait(configurationDB.poolWait);

        return ds;
    }
    return dataSource;
}

From source file:hoot.services.HootServicesSpringConfig.java

@Bean(name = "dataSource")
public DataSource dataSource() {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName("org.postgresql.Driver");
    dataSource.setUrl("jdbc:postgresql://" + env.getProperty("DB_HOST") + ":" + env.getProperty("DB_PORT") + "/"
            + env.getProperty("DB_NAME"));
    dataSource.setUsername(env.getProperty("DB_USER"));
    dataSource.setPassword(env.getProperty("DB_PASSWORD"));
    dataSource.setInitialSize(25);/*from w ww . j  a  v a 2 s  . com*/
    dataSource.setMaxActive(90);
    dataSource.setMaxIdle(30);
    dataSource.setDefaultAutoCommit(false);
    dataSource.setRemoveAbandoned(true);
    dataSource.setLogAbandoned(true);
    return dataSource;
}

From source file:cn.cuizuoli.gotour.config.DataSourceConfig.java

@Bean
public DataSource userDataSource() {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(env.getRequiredProperty("user.jdbc.driverClassName"));
    dataSource.setUrl(env.getRequiredProperty("user.jdbc.url"));
    dataSource.setUsername(env.getRequiredProperty("user.jdbc.username"));
    dataSource.setPassword(env.getRequiredProperty("user.jdbc.password"));
    dataSource.setInitialSize(env.getRequiredProperty("jdbc.initialSize", Integer.class));
    dataSource.setMaxActive(env.getRequiredProperty("jdbc.maxActive", Integer.class));
    dataSource.setMaxIdle(env.getRequiredProperty("jdbc.maxIdle", Integer.class));
    dataSource.setMinIdle(env.getRequiredProperty("jdbc.minIdle", Integer.class));
    dataSource.setDefaultAutoCommit(env.getRequiredProperty("jdbc.defaultAutoCommit", Boolean.class));
    dataSource.setPoolPreparedStatements(env.getRequiredProperty("jdbc.poolPreparedStatements", Boolean.class));
    dataSource.setValidationQuery(env.getRequiredProperty("jdbc.validationQuery"));
    dataSource.setTestOnBorrow(env.getRequiredProperty("jdbc.testOnBorrow", Boolean.class));
    dataSource.setTestOnReturn(env.getRequiredProperty("jdbc.testOnReturn", Boolean.class));
    dataSource.setTestWhileIdle(env.getRequiredProperty("jdbc.testWhileIdle", Boolean.class));
    dataSource.setTimeBetweenEvictionRunsMillis(
            env.getRequiredProperty("jdbc.timeBetweenEvictionRunsMillis", Long.class));
    dataSource.setNumTestsPerEvictionRun(env.getRequiredProperty("jdbc.numTestsPerEvictionRun", Integer.class));
    dataSource.setMinEvictableIdleTimeMillis(
            env.getRequiredProperty("jdbc.minEvictableIdleTimeMillis", Long.class));
    return dataSource;
}