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:aka.pirana.springsecurity.config.PersistenceConfig.java

@Bean
public DataSource dataSource() {
    System.out.println("aka.pirana.springsecurity.config.PersistenceConfig.dataSource()");
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(env.getProperty("jdbc.driverClassName"));
    dataSource.setUrl(env.getProperty("jdbc.url"));
    dataSource.setUsername(env.getProperty("jdbc.username"));
    dataSource.setPassword(env.getProperty("jdbc.password"));
    return dataSource;
}

From source file:com.consol.citrus.samples.todolist.dao.JdbcApplicationConfig.java

@Bean(destroyMethod = "close")
@DependsOn("database")
public BasicDataSource dataSource(JdbcConfigurationProperties configurationProperties) {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(configurationProperties.getDriverClassName());
    dataSource.setUrl(configurationProperties.getUrl());
    dataSource.setUsername(configurationProperties.getUsername());
    dataSource.setPassword(configurationProperties.getPassword());

    return dataSource;
}

From source file:br.com.proj.web.config.WebMvcConfig.java

@Bean
public DataSource dataSource() {
    System.out.println("dataSource");
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(env.getProperty("db.driverClassName"));
    dataSource.setUrl(env.getProperty("db.url"));
    dataSource.setUsername(env.getProperty("db.username"));
    dataSource.setPassword(env.getProperty("db.password"));
    return dataSource;
}

From source file:com.iluwatar.repository.AppConfig.java

/**
 * Creation of H2 db//w ww  .j  av a 2 s . co  m
 * 
 * @return A new Instance of DataSource
 */
@Bean(destroyMethod = "close")
public DataSource dataSource() {
    BasicDataSource basicDataSource = new BasicDataSource();
    basicDataSource.setDriverClassName("org.h2.Driver");
    basicDataSource.setUrl("jdbc:h2:~/databases/person");
    basicDataSource.setUsername("sa");
    basicDataSource.setPassword("sa");
    return (DataSource) basicDataSource;
}

From source file:com.emc.ecs.sync.service.MySQLDbService.java

@Override
protected JdbcTemplate createJdbcTemplate() {
    BasicDataSource ds = new BasicDataSource();
    ds.setUrl(connectString);/*  w w  w . j a  v  a2s. c  o  m*/
    ds.addConnectionProperty("characterEncoding", "UTF-8");
    if (username != null)
        ds.setUsername(username);
    if (password != null)
        ds.setPassword(password);
    ds.setMaxActive(1000);
    ds.setMaxIdle(1000);
    ds.setMaxOpenPreparedStatements(1000);
    ds.setPoolPreparedStatements(true);
    return new JdbcTemplate(ds);
}

From source file:fr.gouv.diplomatie.applitutoriel.integration.conf.DataSourceConf.java

@Bean
public DataSource dataSource() {
    final BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(driverClassName);
    dataSource.setUrl(url);/*w ww .j  av a  2 s.  c  o m*/
    dataSource.setUsername(username);
    dataSource.setPassword(password);
    dataSource.setValidationQuery(validationQuery);
    dataSource.setMaxActive(maxActive);
    dataSource.setMaxIdle(maxIdle);
    dataSource.setMaxWait(maxWait);
    dataSource.setTestOnBorrow(testOnBorrow);
    dataSource.setTestWhileIdle(testWhileIdle);
    dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
    dataSource.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
    dataSource.setRemoveAbandoned(removeAbandoned);
    dataSource.setRemoveAbandonedTimeout(removeAbandonedTimeout);
    dataSource.setLogAbandoned(logAbandoned);
    return dataSource;
}

From source file:io.springagora.store.ApplicationConfig.java

/**
 * Bean definition./*from   ww w  .  java 2 s  . c  o m*/
 * 
 * Datasource used to retrieve connections for the persistence layer. It's
 * configured following definitions written in {@code application.properties}.
 * 
 * @return
 *      The {@code Datasource} object, that will act as the connection pool,
 *      providing connections to the application. 
 * 
 * @throws SQLException
 *      If any error occurs during the connection attempt, it will be thrown
 *      as a {@code SQLException}.
 */
@Bean
public DataSource dataSource() throws SQLException {
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName("com.mysql.jdbc.Driver");
    ds.setUrl(connectionUrl);
    ds.setUsername(username);
    ds.setPassword(password);
    ds.setInitialSize(5);
    ds.setMaxActive(20);
    ds.setDefaultAutoCommit(false);
    return ds;
}

From source file:$.DataSourceConf.java

@Bean
    public DataSource dataSource() {
        final BasicDataSource dataSource = new BasicDataSource();
        dataSource.setDriverClassName(driverClassName);
        dataSource.setUrl(url);//from ww  w  . j a  v a 2s.  c o m
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        dataSource.setValidationQuery(validationQuery);
        dataSource.setMaxActive(maxActive);
        dataSource.setMaxIdle(maxIdle);
        dataSource.setMaxWait(maxWait);
        dataSource.setTestOnBorrow(testOnBorrow);
        dataSource.setTestWhileIdle(testWhileIdle);
        dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
        dataSource.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
        dataSource.setRemoveAbandoned(removeAbandoned);
        dataSource.setRemoveAbandonedTimeout(removeAbandonedTimeout);
        dataSource.setLogAbandoned(logAbandoned);
        return dataSource;
    }

From source file:com.bentechapps.angularcrud.config.SpringApplication.java

private DataSource localDataSource() {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(env.getProperty("spring.datasource.driverClassName"));
    dataSource.setUrl(env.getProperty("spring.datasource.url"));
    dataSource.setUsername(env.getProperty("spring.datasource.username"));
    dataSource.setPassword(env.getProperty("spring.datasource.password"));

    return dataSource;
}

From source file:com.ipet.server.config.JPAConfiguration.java

@Bean
public BasicDataSource dataSource() {
    BasicDataSource ds = new org.apache.commons.dbcp.BasicDataSource();
    ds.setDriverClassName("com.mysql.jdbc.Driver");
    ds.setUrl("jdbc:mysql://localhost:3306/ipet?useUnicode=true&characterEncoding=UTF-8");
    ds.setUsername("root");
    ds.setPassword("");
    return ds;/*from   w w w .j a  va2  s. c  om*/
    /*
     DriverManagerDataSource dataSource = new DriverManagerDataSource();
     dataSource.setDriverClassName("com.mysql.jdbc.Driver");
     dataSource.setUrl("jdbc:mysql://localhost:3306/awp");
     dataSource.setUsername("root");
     dataSource.setPassword("password");
     return null;
     */
}