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(Driver driver, String url, String username, String password) 

Source Link

Document

Create a new DriverManagerDataSource with the given standard Driver parameters.

Usage

From source file:dk.nsi.haiba.minipasconverter.TestConfiguration.java

@Bean
public DataSource haibaDataSource() throws Exception {
    String jdbcUrlPrefix = "jdbc:mysql://127.0.0.1:" + mysqlPort + "/";

    return new SimpleDriverDataSource(new com.mysql.jdbc.Driver(),
            jdbcUrlPrefix + testHAIBADbName + "?createDatabaseIfNotExist=true", testHAIBADbUsername,
            testHAIBADbPassword);// www .  j av a 2 s. co m
}

From source file:com.googlecode.flyway.core.FlywaySmallTest.java

@Test
public void configureWithPartialDbConfigInProperties() {
    DataSource dataSource = new SimpleDriverDataSource(new org.h2.Driver(),
            "jdbc:h2:mem:flyway_test;DB_CLOSE_DELAY=-1", "sa", "");

    Properties properties = new Properties();
    properties.setProperty("flyway.url", "dummy_url");

    Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource);/*  ww w . j ava  2 s.  co  m*/
    flyway.configure(properties);

    assertEquals(dataSource, flyway.getDataSource());
}

From source file:dk.nsi.haiba.lprimporter.integrationtest.LPRIntegrationTestConfiguration.java

@Bean
public DataSource classificationDataSource() throws Exception {
    String jdbcUrlPrefix = "jdbc:mysql://127.0.0.1:" + mysqlPort + "/";

    return new SimpleDriverDataSource(new Driver(),
            jdbcUrlPrefix + testHAIBADbName + "?createDatabaseIfNotExist=true", testHAIBADbUsername,
            testHAIBADbPassword);//ww w  .ja va 2s. com
}

From source file:dk.nsi.haiba.minipasconverter.TestConfiguration.java

@Bean
public DataSource haibaSyncDataSource() throws Exception {
    String jdbcUrlPrefix = "jdbc:mysql://127.0.0.1:" + mysqlPort + "/";

    return new SimpleDriverDataSource(new com.mysql.jdbc.Driver(),
            jdbcUrlPrefix + testHAIBADbName + "?createDatabaseIfNotExist=true", testHAIBADbUsername,
            testHAIBADbPassword);/*from  w ww .  j  ava2  s . c  o  m*/
}

From source file:dk.nsi.haiba.lprimporter.integrationtest.LPRIntegrationTestConfiguration.java

@Bean
public DataSource lprDataSource() throws Exception {
    String jdbcUrlPrefix = "jdbc:mysql://127.0.0.1:" + mysqlPort + "/";

    return new SimpleDriverDataSource(new Driver(),
            jdbcUrlPrefix + testLPRDbName + "?createDatabaseIfNotExist=true", testLPRDbUsername,
            testLPRDbPassword);//from  w w w .  j a  va2  s.  c  o m
}

From source file:dk.nsi.haiba.lprimporter.integrationtest.LPRIntegrationTestConfiguration.java

@Bean
public DataSource lprDataSourceMinipas() throws Exception {
    String jdbcUrlPrefix = "jdbc:mysql://127.0.0.1:" + mysqlPort + "/";

    return new SimpleDriverDataSource(new Driver(),
            jdbcUrlPrefix + testLPRMinipasDbName + "?createDatabaseIfNotExist=true", testLPRDbUsername,
            testLPRDbPassword);/*from   ww  w.  java 2s . c o  m*/
}

From source file:org.processbase.ui.core.Constants.java

public static JdbcTemplate getJdbcTemplate(Properties properties) {
    String driver = properties.getProperty("hibernate.connection.driver_class");
    String url = properties.getProperty("hibernate.connection.url");
    String username = properties.getProperty("hibernate.connection.username");
    String password = properties.getProperty("hibernate.connection.password");
    Driver driverInstance = null;
    try {/*from  ww  w .  jav  a 2 s.c  om*/
        driverInstance = (Driver) Driver.class.forName(driver).newInstance();
        SimpleDriverDataSource dataSource = new SimpleDriverDataSource(driverInstance, url, username, password);
        return new JdbcTemplate(dataSource);

    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    return null;

}

From source file:dk.nsi.haiba.lprimporter.integrationtest.LPRIntegrationTestConfiguration.java

@Bean
public DataSource haibaDataSource() throws Exception {
    String jdbcUrlPrefix = "jdbc:mysql://127.0.0.1:" + mysqlPort + "/";

    return new SimpleDriverDataSource(new Driver(),
            jdbcUrlPrefix + testHAIBADbName + "?createDatabaseIfNotExist=true", testHAIBADbUsername,
            testHAIBADbPassword);/*  w ww.j a  va 2 s .  c o m*/
}

From source file:dk.teachus.backend.test.SpringTestCase.java

@Override
protected String[] getConfigLocations() {
    final List<String> configLocations = new ArrayList<String>();

    configLocations.add("/dk/teachus/backend/applicationContext.xml");
    configLocations.add("/dk/teachus/backend/dao/hibernate/applicationContext-hibernate.xml");
    configLocations.add("/dk/teachus/frontend/applicationContext-frontend.xml");

    DataSource dataSource = null;
    if (SpringTestCase.useMysql) {
        final MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
        ds.setUrl("jdbc:mysql://localhost/teachus_test");
        ds.setUser("teachus_build");
        ds.setPassword("teachus_build");
        dataSource = ds;/*www.  j  a  v  a 2  s.  c  o m*/
        configLocations.add("/dk/teachus/backend/test/applicationContext-test-mysql.xml");
    } else {
        dataSource = new SimpleDriverDataSource(new jdbcDriver(), "jdbc:hsqldb:mem:teachus", "sa", "");
        configLocations.add("/dk/teachus/backend/test/applicationContext-test-hsqldb.xml");
    }

    final SimpleNamingContextBuilder contextBuilder = new SimpleNamingContextBuilder();
    contextBuilder.bind("java:comp/env/jdbc/teachus", dataSource);
    try {
        contextBuilder.activate();
    } catch (final IllegalStateException e) {
        throw new RuntimeException(e);
    } catch (final NamingException e) {
        throw new RuntimeException(e);
    }

    addConfigLocations(configLocations);

    return configLocations.toArray(new String[configLocations.size()]);
}

From source file:be.solidx.hot.spring.config.DataConfig.java

public DataSource oracleSimpleDriverDataSource(String host, int port, String service, String username,
        String password) throws Exception {
    Driver oracleDriver = (Driver) Class.forName("oracle.jdbc.OracleDriver").newInstance();
    return new SimpleDriverDataSource(oracleDriver, String.format(ORACLE_JDBC_URL, host, port, service),
            username, password);//www  .  j a v  a2  s.  c o m
}