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

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

Introduction

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

Prototype

public synchronized void setUsername(String username) 

Source Link

Document

Sets the #username .

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

Usage

From source file:com.mycompany.geocoordinate.config.DataConfig.java

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

    return dataSource;

}

From source file:jp.classmethod.aws.brian.config.DataSourceConfiguration.java

@Bean
public DataSource dataSource() {
    BasicDataSource basicDataSource = new BasicDataSource();
    basicDataSource.setDriverClassName("com.mysql.jdbc.Driver");
    basicDataSource.setUrl(url);/*from w w  w .j  a v  a 2  s  . c  om*/
    basicDataSource.setUsername(username);
    basicDataSource.setPassword(password);
    basicDataSource.setValidationQuery("SELECT 1");
    basicDataSource.setMaxActive(50);
    basicDataSource.setMaxIdle(10);
    basicDataSource.setMinIdle(5);
    return basicDataSource;
}

From source file:example.unittest.ExampleDbUnitTest.java

@Before
public void setup() {
    DbEnvironment db = new UnitTestDbBuilder().setSourcePath("./src/main/database").setReferenceEnvName("test")
            .setDbPlatform(new HsqlDbPlatform()).setDbServer("mytest").buildContext().setupAndCleanAndDeploy()
            .getEnvironment();//  w  w  w.  j  av a2 s.c  o m

    System.out.println("in case you want to see what the url will be: " + db.getJdbcUrl());

    // create the datasource for your test. You have the option to append URL parameters to simulate your actual app conditions if you'd like
    BasicDataSource ds = new BasicDataSource();
    ds.setUrl(db.getJdbcUrl() + ";schema=DEMO_SCHEMA");
    ds.setUsername(db.getDefaultUserId());
    ds.setPassword(db.getDefaultPassword());
    this.ds = ds;
}

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:database.DataSourceBase.java

public DataSource initDataSource() {
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName(driver);/*w w  w. jav  a 2 s.  com*/
    ds.setUsername(username);
    ds.setPassword(password);
    ds.setUrl(url);
    ds.setMaxActive(maxActive);

    datasource = ds;
    return ds;
}

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:mx.com.pixup.portal.dao.CancionParserDaoJdbc.java

public CancionParserDaoJdbc() throws IOException, JDOMException {
    BasicDataSource dataSource = new BasicDataSource();

    //seccion de la DB
    dataSource.setDriverClassName("com.mysql.jdbc.Driver");
    dataSource.setUsername("root");
    dataSource.setPassword("admin");
    //dataSource.setPassword("mysqlroot");
    dataSource.setUrl("jdbc:mysql://localhost:3306/pixup");
    this.dataSource = dataSource;

    //seccion generate XML
    this.xmlParser = new SAXBuilder();
    this.xmlDocumento = this.xmlParser.build(
            "C:\\Users\\JAVA-08\\Documents\\VOSS\\Modulo 5\\pixup-dao-xml\\src\\testXML\\cancion311.xml");
}

From source file:com.btmatthews.mockjndi.datasource.DataSourceBinding.java

@Override
protected synchronized Object createBoundObject() {
    final BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(driver);
    dataSource.setUrl(url);// www . jav a  2  s  .c  om
    if (user != null) {
        dataSource.setUsername(user);
        if (password != null) {
            dataSource.setPassword(password);
        }
    }
    return dataSource;
}

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.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);/*  w ww. ja v a2 s.  c  o m*/
    TransactionLogStorage storage = new RdbTransactionLogStorage(dataSource);
    assertTransactionLogStorageOperations(storage);
}