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

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

Introduction

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

Prototype

public synchronized void setDriverClassName(String driverClassName) 

Source Link

Document

Sets the jdbc driver class name.

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

Usage

From source file:org.smart.migrate.util.ConnectionUtils.java

/**
 * Create datasource by dbsettign// w w  w  .  ja  v  a2 s.c om
 * ?????
 * @param dBSetting
 * @return
 */
public static DataSource createDataSource(DBSetting dBSetting) {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(dBSetting.getdBType().getDriver());
    dataSource.setUrl(dBSetting.getConnectUrl());
    dataSource.setUsername(dBSetting.getUsername());
    dataSource.setPassword(dBSetting.getPassword());
    return dataSource;
}

From source file:org.snaker.engine.access.jdbc.JdbcHelper.java

/**
 * dataSourcedbcp??//from www  .  j  av  a 2  s .  c  o m
 */
private static void initialize() {
    String driver = ConfigHelper.getProperty("jdbc.driver");
    String url = ConfigHelper.getProperty("jdbc.url");
    String username = ConfigHelper.getProperty("jdbc.username");
    String password = ConfigHelper.getProperty("jdbc.password");
    int maxActive = ConfigHelper.getNumerProperty("jdbc.max.active");
    int maxIdle = ConfigHelper.getNumerProperty("jdbc.max.idle");
    AssertHelper.notNull(driver);
    AssertHelper.notNull(url);
    AssertHelper.notNull(username);
    AssertHelper.notNull(password);
    //?DBCP??
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName(driver);
    ds.setUrl(url);
    ds.setUsername(username);
    ds.setPassword(password);
    if (maxActive != 0) {
        ds.setMaxActive(maxActive);
    }
    if (maxIdle != 0) {
        ds.setMaxIdle(maxIdle);
    }
    dataSource = ds;
}

From source file:org.sonar.core.persistence.DbTemplate.java

public BasicDataSource dataSource(String driver, String user, String password, String url) {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(driver);
    dataSource.setUsername(user);//from   w  ww .j  av a  2s .c  o  m
    dataSource.setPassword(password);
    dataSource.setUrl(url);
    return dataSource;
}

From source file:org.spc.ofp.observer.config.ObserverDataSourceConfig.java

@Primary
@Bean(destroyMethod = "close", name = { "jdbcDataSource" })
public DataSource jdbcDataSource() {
    final BasicDataSource bds = new BasicDataSource();
    bds.setDriverClassName(DRIVER_CLASS);
    bds.setUrl(OBSERVER_URL);//  ww w.j  a  va 2  s  . c  o  m
    return bds;
}

From source file:org.springframework.batch.sample.config.DataSourceConfiguration.java

@Bean(destroyMethod = "close")
public DataSource dataSource() {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(environment.getProperty("batch.jdbc.driver"));
    dataSource.setUrl(environment.getProperty("batch.jdbc.url"));
    dataSource.setUsername(environment.getProperty("batch.jdbc.user"));
    dataSource.setPassword(environment.getProperty("batch.jdbc.password"));
    return dataSource;
}

From source file:org.springframework.batch.support.DatabaseTypeTestUtils.java

public static DataSource getDataSource(Class<?> driver, String url, String username, String password)
        throws Exception {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(driver.getName());
    dataSource.setUrl(url);//from   ww  w.j a va2 s  . c  o m
    dataSource.setUsername(username);
    dataSource.setPassword(password);
    return dataSource;
}

From source file:org.springframework.samples.petclinic.config.DbcpDataSourceFactory.java

private BasicDataSource createDataSource() {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(this.driverClassName);
    dataSource.setUrl(this.url);
    dataSource.setUsername(this.username);
    dataSource.setPassword(this.password);
    return dataSource;
}

From source file:org.tdmx.lib.control.datasource.DynamicDataSource.java

private synchronized void createDataSource(DatabaseConnectionInfo dci) throws SQLException {
    // race condition avoidance
    if (connectionDataSourceMap.get(dci) != null) {
        return;/*  w w w .j  a  v a 2s .com*/
    }
    BasicDataSource bds = new BasicDataSource();
    bds.setUrl(dci.getUrl());
    bds.setDriverClassName(dci.getDriverClassname());
    bds.setUsername(dci.getUsername());
    bds.setPassword(dci.getPassword());
    bds.setMaxActive(100);
    bds.setMinIdle(0);
    bds.setInitialSize(1);
    bds.setMinEvictableIdleTimeMillis(60000);
    bds.setLogWriter(logWriter);
    connectionDataSourceMap.put(dci, bds);
}

From source file:org.unidle.config.DataConfiguration.java

@Bean(destroyMethod = "close")
public DataSource dataSource() {
    final BasicDataSource dataSource = new BasicDataSource();

    dataSource.setDriverClassName(dataSourceDriverClass);
    dataSource.setUrl(dataSourceUrl);//from w w w  .j a  v  a2 s  .  c o  m
    dataSource.setUsername(dataSourceUsername);
    dataSource.setPassword(dataSourcePassword);

    return dataSource;
}

From source file:org.unitils.database.config.PropertiesDataSourceFactory.java

public DataSource createDataSource() {
    logger.info("Creating data source. Driver: " + config.getDriverClassName() + ", url: " + config.getUrl()
            + ", user: " + config.getUserName() + ", password: <not shown>");
    BasicDataSource dataSource = getNewDataSource();
    dataSource.setDriverClassName(config.getDriverClassName());
    dataSource.setUsername(config.getUserName());
    dataSource.setPassword(config.getPassword());
    dataSource.setUrl(config.getUrl());//  w w w. j a va  2s  . c o  m
    return dataSource;

}