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:flywayspike.Main.java

/**
 * Runs the sample.//  w  w  w  .  ja v  a  2 s .co  m
 *
 * @param args None supported.
 */
public static void main(String[] args) throws Exception {
    DataSource dataSource = new SimpleDriverDataSource(new org.hsqldb.jdbcDriver(),
            "jdbc:hsqldb:file:db/flyway_sample;shutdown=true", "SA", "");
    Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource);
    flyway.setLocations("flywayspike.migration", "abcd");
    flyway.clean();

    System.out.println("Started Migration");
    flyway.migrate();
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    List<Map<String, Object>> results = jdbcTemplate.queryForList("select name from test_user");
    for (Map<String, Object> result : results) {
        System.out.println("Name: " + result.get("NAME"));
    }

    SqlRowSet rowSet = jdbcTemplate.queryForRowSet("select * from schema_version");
    while (rowSet.next()) {
        System.out.print(rowSet.getObject(1));
        System.out.println("  " + rowSet.getObject(2));
    }
}

From source file:edu.wisc.jmeter.dao.JdbcMonitorDaoTest.java

@Before
public void setup() throws Exception {
    this.ds = new SimpleDriverDataSource(new jdbcDriver(), "jdbc:hsqldb:mem:JdbcMonitorTest", "sa", "");
    this.jdbcTemplate = new JdbcTemplate(this.ds);
    SimpleJdbcTestUtils.executeSqlScript(new SimpleJdbcTemplate(this.jdbcTemplate),
            new ClassPathResource("/tables_hsql.sql"), false);

    this.jdbcMonitorDao = new JdbcMonitorDao(this.ds, Integer.MAX_VALUE, Integer.MAX_VALUE);
    this.jdbcMonitorDao.afterPropertiesSet();
}

From source file:org.jasig.portal.cas.authentication.handler.support.PortalPersonDirUserPasswordDaoTest.java

@Override
protected void setUp() throws Exception {
    this.dataSource = new SimpleDriverDataSource(new org.hsqldb.jdbcDriver(), "jdbc:hsqldb:mem:CasTest", "sa",
            "");/*from ww  w.  ja va  2s.c o  m*/

    this.jdbcTemplate = new JdbcTemplate(this.dataSource);
    this.jdbcTemplate
            .execute("CREATE TABLE UP_PERSON_DIR (USER_NAME VARCHAR(1000), ENCRPTD_PSWD VARCHAR(1000))");

    this.userPasswordDao = new PortalPersonDirUserPasswordDao();
    this.userPasswordDao.setDataSource(this.dataSource);
}

From source file:org.jasig.cas.ticket.registry.support.JdbcLockingStrategyTests.java

/**
 * @throws  Exception on test setup.//w w w  .  j  a  v  a 2s .co  m
 */
public void setUp() throws Exception {
    super.setUp();
    this.testDataSource = new SimpleDriverDataSource(new org.hsqldb.jdbcDriver(), "jdbc:hsqldb:mem:locktest",
            "sa", "");
    final JdbcTemplate tmpl = new JdbcTemplate(this.testDataSource);
    tmpl.execute(CREATE_TABLE_SQL);
    tmpl.execute(CREATE_PRI_KEY_SQL);
}

From source file:com.joshlong.activiti.coordinator.registration1.distribution.producer.RegistrationProducerConfiguration.java

@Bean
public DataSource activitiDataSource() {
    return new SimpleDriverDataSource(new org.h2.Driver(), "jdbc:h2:tcp://localhost/~/activiti_example3", "sa",
            "");//from  w  w  w.  j  av  a2  s  .  co  m
}

From source file:org.terasoluna.gfw.web.logging.TraceLoggingInterceptorTest.java

@Before
public void setUp() throws Exception {
    // reset log//from w w  w  . ja v  a2  s  .  c  om
    new SimpleDriverDataSource(Driver.load(),
            "jdbc:h2:mem:terasolung-gfw-web;DB_CLOSE_DELAY=-1;INIT=RUNSCRIPT FROM 'classpath:h2.sql'", "sa", "")
                    .getConnection().close();

    // prepare request object
    request = new MockHttpServletRequest();

    // prepare response object
    response = new MockHttpServletResponse();

    controller = new TraceLoggingInterceptorController();
    method = controller.getClass().getMethods();

    model = mock(ModelAndView.class);

    interceptor = new TraceLoggingInterceptor();
}

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

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

    Properties properties = new Properties();

    Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource);/*from   www . j av  a2  s . c  o  m*/
    flyway.configure(properties);

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

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

@Bean
public DataSource minipasDataSource() throws Exception {
    String jdbcUrlPrefix = "jdbc:db2://127.0.0.1:50000/HAIBA";

    // not in maven, only works in eclipse
    Driver d = (Driver) Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
    return new SimpleDriverDataSource(d, jdbcUrlPrefix, "db2inst1", "db2inst1");
}

From source file:org.apereo.services.persondir.support.jdbc.AbstractCaseSensitivityJdbcPersonAttributeDaoTest.java

@Override
protected void setUp() throws Exception {
    super.setUp();
    this.testDataSource = new SimpleDriverDataSource(new jdbcDriver(), "jdbc:hsqldb:mem:adhommemds", "sa", "");
    setUpSchema(testDataSource);// ww  w .j a v  a 2  s.com
}

From source file:dk.nsi.haiba.epimibaimporter.integrationtest.EPIMIBAIntegrationTestConfiguration.java

@Bean
@Qualifier("haibaDataSource")
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);/*  ww  w. ja  v  a 2  s.  co  m*/
}