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.gantzgulch.sharing.configuration.DataSourceContextTest.java

@Bean(name = "sharingDS")
public DataSource sharingDataSource() {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
    dataSource.setUrl("jdbc:hsqldb:mem:sharing_db");
    dataSource.setUsername("sa");
    dataSource.setPassword("");
    return dataSource;
}

From source file:com.dangdang.ddframe.job.event.rdb.JobEventRdbConfigurationTest.java

@Test
public void assertGetDataSource() throws JobEventListenerConfigurationException {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(org.h2.Driver.class.getName());
    dataSource.setUrl("jdbc:h2:mem:job_event_storage");
    dataSource.setUsername("sa");
    dataSource.setPassword("");
    assertThat((BasicDataSource) (new JobEventRdbConfiguration(dataSource).getDataSource()), is(dataSource));
}

From source file:com.dangdang.ddframe.job.event.rdb.JobEventRdbConfigurationTest.java

@Test
public void assertCreateJobEventListenerSuccess() throws JobEventListenerConfigurationException {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(org.h2.Driver.class.getName());
    dataSource.setUrl("jdbc:h2:mem:job_event_storage");
    dataSource.setUsername("sa");
    dataSource.setPassword("");
    assertThat(new JobEventRdbConfiguration(dataSource).createJobEventListener(),
            instanceOf(JobEventRdbListener.class));
}

From source file:com.dangdang.ddframe.rdb.transaction.soft.integrate.storage.RdbTransactionLogStorageOperationsTest.java

@Test
public void assertRdbTransactionLogStorageOperations() throws SQLException {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(org.h2.Driver.class.getName());
    dataSource.setUrl("jdbc:h2:mem:db_transaction_storage");
    dataSource.setUsername("sa");
    dataSource.setPassword("");
    createTable(dataSource);//from   w  w  w .  j  a  v  a 2s  .c  om
    TransactionLogStorage storage = new RdbTransactionLogStorage(dataSource);
    assertTransactionLogStorageOperations(storage);
}

From source file:com.gantzgulch.sharing.configuration.DataSourceContextProduction.java

@Bean(name = "sharingDS")
public DataSource sharingDataSource() {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
    dataSource.setUrl("jdbc:hsqldb:file:" + storageLocation + "/sharing_db");
    dataSource.setUsername("sa");
    dataSource.setPassword("");
    return dataSource;
}

From source file:com.example.dbflute.spring.JdbcBeansJavaConfig.java

@Bean(name = { "dataSource" })
public DataSource createDataSource() {
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName("org.h2.Driver");
    ds.setUrl(exampleDbUrl);/*from w w w  .jav a  2s  . c o  m*/
    ds.setUsername("sa");
    ds.setPassword("");
    ds.setMaxActive(20);
    return ds;
}

From source file:config.DomainAndPersistenceConfig.java

@Bean
public DataSource dataSource() {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName("com.mysql.jdbc.Driver");
    dataSource.setUrl("jdbc:mysql://localhost:3306/cabinet");
    dataSource.setUsername("root");
    dataSource.setPassword("");
    return dataSource;
}

From source file:com.alibaba.druid.pool.DBCPTest.java

public void test_dbcp() throws Exception {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(MockDriver.class.getName());
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setMaxOpenPreparedStatements(100);
    dataSource.setPoolPreparedStatements(true);

    final String sql = "selelct 1";
    {/*  ww w .j  a va 2 s  . c  om*/
        Connection conn = dataSource.getConnection();
        CallableStatement stmt = conn.prepareCall(sql);
        stmt.close();
        conn.close();
    }
    {
        Connection conn = dataSource.getConnection();
        CallableStatement stmt = conn.prepareCall(sql);
        stmt.close();
        conn.close();
    }
}

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

public MaintenanceDao(String driver, String url, String uname, String pwd) {
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName(driver);
    ds.setUrl(url);//from  w w w. j a v  a  2s. com
    ds.setUsername(uname);
    ds.setPassword(pwd);
    this.jdbcTemplate = new JdbcTemplate(ds);
    testConnection();
}

From source file:gestores.PoolDeConexiones.java

protected void pedirConexion() throws Exception {
    if (conexion == null) {
        try {//w w  w .  j  a v a  2s. com
            BasicDataSource basicDataSource = new BasicDataSource();
            basicDataSource.setDriverClassName("com.mysql.jdbc.Driver");
            basicDataSource.setUrl("jdbc:mysql://localhost:3306/osg");
            basicDataSource.setUsername("root");
            basicDataSource.setPassword("root");
            basicDataSource.setMaxActive(20);
            basicDataSource.setMaxIdle(2);
            conexion = basicDataSource.getConnection();
            conexion.setAutoCommit(false);
        } catch (SQLException e) {
            throw new Exception(e.getMessage());
        }
    }
}