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:com.taobao.tddl.jdbc.group.testutil.DataSourceFactory.java

public static DataSource getLocalMySQLDataSource(int num) {
    if (num > 3)
        num = 1;//from  w w  w .ja  v  a2  s  .  co m
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName("com.mysql.jdbc.Driver");
    ds.setUsername("root");
    ds.setPassword("zhh");
    ds.setUrl("jdbc:mysql://localhost/group_test_" + num);
    return ds;

}

From source file:cn.com.sims.crawler.util.JDBCHelper.java

public static JdbcTemplate createMysqlTemplate(String templateName, String url, String username,
        String password, int initialSize, int maxActive) {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName("com.mysql.jdbc.Driver");
    dataSource.setUrl(url);//from  w w w  . j av  a 2s.  c om
    dataSource.setUsername(username);
    dataSource.setPassword(password);
    dataSource.setInitialSize(initialSize);
    dataSource.setMaxActive(maxActive);
    JdbcTemplate template = new JdbcTemplate(dataSource);
    templateMap.put(templateName, template);
    return template;
}

From source file:com.dangdang.ddframe.rdb.sharding.config.yaml.AbstractYamlShardingDataSourceTest.java

protected static DataSource createDataSource(final String dsName) {
    BasicDataSource result = new BasicDataSource();
    result.setDriverClassName(org.h2.Driver.class.getName());
    result.setUrl(String.format("jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL", dsName));
    result.setUsername("sa");
    result.setPassword("");
    result.setMaxActive(100);//from w  w w .  j av a  2s .c o  m
    return result;
}

From source file:com.flytxt.commons.reporting.connection.ConnectionProvider.java

private static DataSource getDs() {
    if (ds == null) {
        BasicDataSource bds = new BasicDataSource();
        bds.setDriverClassName(DbConnectionPropertiesProvider.getDriver());
        bds.setUrl(DbConnectionPropertiesProvider.getUrl());
        bds.setUsername(DbConnectionPropertiesProvider.getUser());
        bds.setPassword(DbConnectionPropertiesProvider.getPwd());

        // Logger.getLogger(ConnectionProvider.class.getName()).log(Level.INFO,"Num Active : "+bds.getNumActive());
        // Logger.getLogger(ConnectionProvider.class.getName()).log(Level.INFO,"Num Idle : "+bds.getNumIdle());

        ds = bds;// w  ww . ja v a 2  s .  c o  m

    }

    return ds;
}

From source file:br.com.linuxgames.model.dao.core.LinuxGamesDataSource.java

private static DataSource setupDataSource() {
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName("com.mysql.jdbc.Driver");
    ds.setUsername("boaglio_linuxgam");
    ds.setPassword("boaglio_linuxgam");
    ds.setUrl("jdbc:mysql://localhost/linuxgames");
    return ds;/*from w  ww.j  a  v a  2s.  c  o  m*/
}

From source file:com.surveypanel.form.TestHelper.java

public static DataSource getDataSource() {
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName("com.mysql.jdbc.Driver");
    ds.setUsername("root");
    ds.setPassword("halflife");
    ds.setUrl(/*from   ww w .  j av  a2s.  c  o m*/
            "jdbc:mysql://localhost:3306/surveypanel?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8");
    return ds;
}

From source file:com.dangdang.ddframe.rdb.sharding.example.jdbc.Main.java

private static DataSource createDataSource(final String dataSourceName) {
    BasicDataSource result = new BasicDataSource();
    result.setDriverClassName(com.mysql.jdbc.Driver.class.getName());
    result.setUrl(String.format("jdbc:mysql://localhost:3306/%s", dataSourceName));
    result.setUsername("root");
    result.setPassword("");
    return result;
}

From source file:com.googlecode.wmbutil.cache.LookupDataSourceFactory.java

public static synchronized LookupDataSource getDataSource() throws CacheRefreshException {
    if (dataSource == null) {
        try {/* ww  w  . j  ava2s .co m*/
            Properties config = new Properties();
            config.load(new FileInputStream("lookup-connection.properties"));

            BasicDataSource ds = new BasicDataSource();
            ds.setDriverClassName(config.getProperty("lookup.class"));
            ds.setUrl(config.getProperty("lookup.url"));
            ds.setUsername(config.getProperty("lookup.username"));
            ds.setPassword(config.getProperty("lookup.password"));
            ds.setDefaultReadOnly(false);

            dataSource = new JdbcLookupDataSource(ds);
        } catch (FileNotFoundException e) {
            throw new CacheRefreshException("Could not find lookup-connection.properties file", e);
        } catch (IOException e) {
            throw new CacheRefreshException("Found, but could not read from lookup-connection.properties file",
                    e);
        } catch (RuntimeException e) {
            throw new CacheRefreshException("Could not create data source", e);
        }
    }

    return dataSource;
}

From source file:com.dangdang.ddframe.job.example.JavaLiteJobMain.java

private static DataSource setUpEventTraceDataSource() {
    BasicDataSource result = new BasicDataSource();
    result.setDriverClassName(EVENT_RDB_STORAGE_DRIVER);
    result.setUrl(EVENT_RDB_STORAGE_URL);
    result.setUsername(EVENT_RDB_STORAGE_USERNAME);
    result.setPassword(EVENT_RDB_STORAGE_PASSWORD);
    return result;
}

From source file:com.cgdecker.guice.jdbc.Hsqldb.java

public static DataSource getDataSource() {
    BasicDataSource result = new BasicDataSource();
    result.setDriverClassName(jdbcDriver.class.getName());
    result.setUrl("jdbc:hsqldb:mem:.");
    result.setUsername("sa");
    result.setPassword("");
    setUpDatabase(result);/*from  ww  w .  j a  va2  s . co m*/
    return result;
}