Example usage for org.springframework.jdbc.datasource SimpleDriverDataSource SimpleDriverDataSource

List of usage examples for org.springframework.jdbc.datasource SimpleDriverDataSource SimpleDriverDataSource

Introduction

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

Prototype

public SimpleDriverDataSource() 

Source Link

Document

Constructor for bean-style configuration.

Usage

From source file:com.emo.ananas.configs.DataSourceConfig.java

public DataSource build() {
    if (user != null && driverClass != null) {
        final SimpleDriverDataSource ds = new SimpleDriverDataSource();
        ds.setUrl(url);/*  w ww .ja va  2s . co m*/
        ds.setDriverClass(driverClass);
        ds.setUsername(user);
        ds.setPassword(password);

        return ds;
    } else if (user != null && driverClass == null) {
        return new DriverManagerDataSource(url, user, password);
    } else if (user == null & driverClass != null) {
        final SimpleDriverDataSource ds = new SimpleDriverDataSource();
        ds.setUrl(url);
        ds.setDriverClass(driverClass);

        return ds;
    } else {
        return new DriverManagerDataSource(url);
    }
}

From source file:org.springsource.greenbeans.examples.edawithspring.etailer.backoffice.PartnerNotificationConfiguration.java

@Bean
public DataSource dataSource() {
    SimpleDriverDataSource simpleDriverDataSource = new SimpleDriverDataSource();
    simpleDriverDataSource.setPassword(this.dsPassword);
    simpleDriverDataSource.setUsername(this.dsUser);
    simpleDriverDataSource.setDriverClass(org.h2.Driver.class);
    simpleDriverDataSource.setUrl(this.dsUrl);
    return simpleDriverDataSource;
}

From source file:com.springsource.html5expense.config.ComponentConfig.java

@Bean
public DataSource dataSource() {
    SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
    dataSource.setUrl(String.format("jdbc:postgresql://%s:%s/%s", "192.168.6.30", 5432, "postgres"));
    dataSource.setDriverClass(org.postgresql.Driver.class);
    dataSource.setUsername("postgres");
    dataSource.setPassword("pramati123");
    return dataSource;
}

From source file:com.gopivotal.cloudfoundry.test.core.DataSourceUtilsTest.java

@Test
public void simpleDriverUrl() {
    SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
    dataSource.setUrl(TEST_URL);//from  w ww . ja va2  s  .c o  m
    assertEquals(TEST_URL, this.dataSourceUtils.getUrl(dataSource));
}

From source file:org.springsource.html5expenses.config.ServicesConfiguration.java

@Bean
@SuppressWarnings("unchecked")
public DataSource dataSource() throws Exception {
    SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
    dataSource.setPassword(environment.getProperty("dataSource.password"));
    dataSource.setUrl(environment.getProperty("dataSource.url"));
    dataSource.setUsername(environment.getProperty("dataSource.user"));
    dataSource.setDriverClass((Class<Driver>) Class.forName(environment.getProperty("dataSource.driverClass")));
    return dataSource;
}

From source file:com.ex.Dao.impl.GroupDaoImpl.java

private DataSource getDataSource() {
    SimpleDriverDataSource simpleDriverDataSource = new SimpleDriverDataSource();
    simpleDriverDataSource.setDriver(new oracle.jdbc.driver.OracleDriver());
    simpleDriverDataSource.setUrl("jdbc:oracle:thin:@localhost:1521:XE");
    simpleDriverDataSource.setUsername("root");
    simpleDriverDataSource.setPassword("killer");
    return simpleDriverDataSource;

}

From source file:org.netxilia.api.impl.storage.DataSourceConfigurationServiceImpl.java

@SuppressWarnings("unchecked")
public DataSource buildSimpleDataSource(DataSourceConfiguration cfg) {
    SimpleDriverDataSource dataSource = new SimpleDriverDataSource();

    Class<? extends Driver> driverClass;
    try {// ww  w  .j  a  va  2  s.c  o  m
        driverClass = (Class<? extends Driver>) Class.forName(cfg.getDriverClassName());
    } catch (ClassNotFoundException e) {
        throw new NetxiliaResourceException("Cannot find class driver:" + cfg.getDriverClassName());
    }
    dataSource.setDriverClass(driverClass);
    dataSource.setUrl(cfg.getUrl().replace(NETXILIA_HOME_VAR, path));
    dataSource.setUsername(cfg.getUsername());
    dataSource.setPassword(cfg.getPassword());
    return dataSource;
}

From source file:org.openflamingo.engine.hive.HiveServiceImpl.java

@Override
public List<String> getDatabases(HiveServer hiveServer) {
    try {//from  w w  w. j a va  2 s .co m
        SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
        dataSource.setDriverClass(org.apache.hive.jdbc.HiveDriver.class);
        dataSource.setUrl(hiveServer.getJdbcUrl());

        final List<String> list = new ArrayList<String>();
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
        jdbcTemplate.query("show databases", new RowCallbackHandler() {
            @Override
            public void processRow(ResultSet resultSet) throws SQLException {
                list.add(resultSet.getString("database_name"));
            }
        });
        return list;
    } catch (Exception ex) {
        throw new ServiceException(message("S_HIVE", "CANNOT_GET_HIVE_DBS"), ex);
    }
}