Example usage for org.springframework.jdbc.datasource DriverManagerDataSource setUsername

List of usage examples for org.springframework.jdbc.datasource DriverManagerDataSource setUsername

Introduction

In this page you can find the example usage for org.springframework.jdbc.datasource DriverManagerDataSource setUsername.

Prototype

public void setUsername(@Nullable String username) 

Source Link

Document

Set the JDBC username to use for connecting through the Driver.

Usage

From source file:be.wolkmaan.klimtoren.web.config.PersistenceConfig.java

@Bean
public DataSource dataSource() {
    DriverManagerDataSource ds = new DriverManagerDataSource();
    ds.setDriverClassName(env.getProperty("jdbc.driverClassName"));
    ds.setUrl(env.getProperty("jdbc.url"));
    ds.setUsername(env.getProperty("jdbc.username"));
    ds.setPassword(env.getProperty("jdbc.password"));
    return ds;/*  w ww. j  av  a2  s  . c o  m*/
}

From source file:com.dynamobi.ws.util.UserToDataSource.java

public UserToDataSource() throws ClassNotFoundException, IOException {
    super();//from w  ww  .j a v  a  2s .  com

    Properties pro = new Properties();

    InputStream user_props = this.getClass().getResourceAsStream("/luciddb-jdbc.properties");
    if (user_props != null) {
        pro.load(user_props);
    } else {
        pro.load(this.getClass().getResourceAsStream("/luciddb-jdbc-default.properties"));
    }

    String jdbc_driver = pro.getProperty("jdbc.driver");
    Class.forName(jdbc_driver);

    String username = pro.getProperty("jdbc.username");
    String password = pro.getProperty("jdbc.password");
    String jdbc_url = pro.getProperty("jdbc.url");

    // this sets up the connection to validate other connections.
    DriverManagerDataSource data_source = new DriverManagerDataSource();
    data_source.setDriverClassName(jdbc_driver);
    data_source.setUrl(jdbc_url);
    data_source.setUsername(username);
    data_source.setPassword(password);
    setTargetDataSource(data_source);
}

From source file:com.xiovr.unibot.config.JdbcConfig.java

/**
 * @return create bean for jdbc driver//from w w w.  j a  va  2 s.  c o m
 */
@Bean(name = "dataSource")
public DataSource getDataSource() {
    DriverManagerDataSource ds = new DriverManagerDataSource();
    ds.setDriverClassName(env.getProperty("jdbc.driverClassName"));
    ds.setUrl(env.getProperty("jdbc.url"));
    ds.setUsername(env.getProperty("jdbc.username"));
    ds.setPassword(env.getProperty("jdbc.password"));
    return ds;
    //      EmbeddedDatabaseBuilder edb = new EmbeddedDatabaseBuilder();
    //      edb.setType(EmbeddedDatabaseType.HSQL).
    //         setName("e5botdb").
    //         addScripts("classpath:/sql/hsql_create.sql",
    //               "classpath:/sql/hsql_data.sql");

    //      return edb.build();
}

From source file:edu.chalmers.dat076.moviefinder.config.RepositoryConfig.java

@Bean
public DataSource dataSource() {
    DriverManagerDataSource ds = new DriverManagerDataSource();
    ds.setDriverClassName(jdbcDriverClassName);
    ds.setUrl(jdbcUrl);/*w  w w. ja v  a2s  .  c o m*/
    ds.setUsername(jdbcUsername);
    ds.setPassword(jdbcPassword);
    return ds;
}

From source file:com.oasisdigital.sdre.ApplicationConfig.java

/**
 * Bootstraps an in-memory HSQL database.
 * //w  ww . ja va 2  s .com
 * @return
 * @see http 
 *      ://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/jdbc.html#jdbc-embedded-database
 *      -support
 */
@Bean
public DataSource dataSource() {
    DriverManagerDataSource ds = new DriverManagerDataSource();
    ds.setDriverClassName("org.hsqldb.jdbcDriver");
    ds.setUrl("jdbc:hsqldb:file:OD-test-db");
    ds.setUsername("sa");
    ds.setPassword("");
    return ds;
}

From source file:contact.config.MvcConfiguration.java

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

    return dataSource;
}

From source file:com.navita.mavenproject4.config.JpaConfig.java

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

From source file:camelinaction.JdbcTest.java

protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry jndi = super.createRegistry();
    jndi.bind("orderToSql", new OrderToSqlBean());

    DriverManagerDataSource ds = new DriverManagerDataSource();
    ds.setDriverClassName("org.hsqldb.jdbcDriver");
    ds.setUrl("jdbc:hsqldb:mem:order");
    ds.setUsername("sa");
    ds.setPassword("");

    jndi.bind("dataSource", ds);
    return jndi;/*from   ww  w  .  j  a v  a 2 s .c  om*/
}

From source file:com.xinferin.config.MvcConfiguration.java

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

    return dataSource;
}

From source file:com.ar.dev.tierra.api.config.DatabaseConfig.java

/**
 * Bean dataSource encargado de la configuracion de conexion con la base de
 * datos.//w ww  .j a va 2s  .c  om
 *
 * @return objeto con la correspondiente conexion a base de datos.
 */
@Bean
public DataSource dataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName(DB_DRIVER);
    dataSource.setUrl(DB_URL);
    dataSource.setUsername(DB_USERNAME);
    dataSource.setPassword(DB_PASSWORD);
    return dataSource;
}