Search in sources :

Example 11 with SimpleDriverDataSource

use of org.springframework.jdbc.datasource.SimpleDriverDataSource in project Activiti by Activiti.

the class ActivitiEngineConfiguration method dataSource.

@Bean
public DataSource dataSource() {
    SimpleDriverDataSource ds = new SimpleDriverDataSource();
    try {
        @SuppressWarnings("unchecked") Class<? extends Driver> driverClass = (Class<? extends Driver>) Class.forName(environment.getProperty("jdbc.driver", "org.h2.Driver"));
        ds.setDriverClass(driverClass);
    } catch (Exception e) {
        log.error("Error loading driver class", e);
    }
    // Connection settings
    ds.setUrl(environment.getProperty("jdbc.url", "jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000"));
    ds.setUsername(environment.getProperty("jdbc.username", "sa"));
    ds.setPassword(environment.getProperty("jdbc.password", ""));
    return ds;
}
Also used : Driver(java.sql.Driver) SimpleDriverDataSource(org.springframework.jdbc.datasource.SimpleDriverDataSource) ProcessEngineFactoryBean(org.activiti.spring.ProcessEngineFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 12 with SimpleDriverDataSource

use of org.springframework.jdbc.datasource.SimpleDriverDataSource in project camunda-bpm-platform by camunda.

the class InMemProcessEngineConfiguration method dataSource.

@Bean
public DataSource dataSource() {
    SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
    dataSource.setDriverClass(org.h2.Driver.class);
    dataSource.setUrl("jdbc:h2:mem:camunda-test;DB_CLOSE_DELAY=-1");
    dataSource.setUsername("sa");
    dataSource.setPassword("");
    return dataSource;
}
Also used : SimpleDriverDataSource(org.springframework.jdbc.datasource.SimpleDriverDataSource) ProcessEngineFactoryBean(org.camunda.bpm.engine.spring.ProcessEngineFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 13 with SimpleDriverDataSource

use of org.springframework.jdbc.datasource.SimpleDriverDataSource in project cas by apereo.

the class JpaBeans method newDataSource.

/**
 * New simple data source.
 *
 * @param driverClass the driver class
 * @param username    the username
 * @param password    the password
 * @param url         the url
 * @return the data source
 */
@SneakyThrows
public static DataSource newDataSource(final String driverClass, final String username, final String password, final String url) {
    val ds = new SimpleDriverDataSource();
    ds.setDriverClass((Class<Driver>) Class.forName(driverClass));
    ds.setUsername(username);
    ds.setPassword(password);
    ds.setUrl(url);
    return ds;
}
Also used : lombok.val(lombok.val) Driver(java.sql.Driver) SimpleDriverDataSource(org.springframework.jdbc.datasource.SimpleDriverDataSource) SneakyThrows(lombok.SneakyThrows)

Example 14 with SimpleDriverDataSource

use of org.springframework.jdbc.datasource.SimpleDriverDataSource in project spring-boot by spring-projects.

the class FlywayAutoConfigurationTests method overrideDataSourceAndDriverClassName.

@Test
void overrideDataSourceAndDriverClassName() {
    String jdbcUrl = "jdbc:hsqldb:mem:flyway" + UUID.randomUUID();
    String driverClassName = "org.hsqldb.jdbcDriver";
    this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class).withPropertyValues("spring.flyway.url:" + jdbcUrl, "spring.flyway.driver-class-name:" + driverClassName).run((context) -> {
        Flyway flyway = context.getBean(Flyway.class);
        SimpleDriverDataSource dataSource = (SimpleDriverDataSource) flyway.getConfiguration().getDataSource();
        assertThat(dataSource.getUrl()).isEqualTo(jdbcUrl);
        assertThat(dataSource.getDriver().getClass().getName()).isEqualTo(driverClassName);
    });
}
Also used : Flyway(org.flywaydb.core.Flyway) SimpleDriverDataSource(org.springframework.jdbc.datasource.SimpleDriverDataSource) Test(org.junit.jupiter.api.Test)

Example 15 with SimpleDriverDataSource

use of org.springframework.jdbc.datasource.SimpleDriverDataSource in project spring-boot by spring-projects.

the class DataSourceBuilderTests method buildWhenSimpleDriverTypeSpecifiedReturnsExpectedDataSource.

@Test
void buildWhenSimpleDriverTypeSpecifiedReturnsExpectedDataSource() {
    this.dataSource = DataSourceBuilder.create().url("jdbc:h2:test").type(SimpleDriverDataSource.class).build();
    assertThat(this.dataSource).isInstanceOf(SimpleDriverDataSource.class);
    SimpleDriverDataSource simpleDriverDataSource = (SimpleDriverDataSource) this.dataSource;
    assertThat(simpleDriverDataSource.getUrl()).isEqualTo("jdbc:h2:test");
    assertThat(simpleDriverDataSource.getDriver()).isInstanceOf(Driver.class);
}
Also used : SimpleDriverDataSource(org.springframework.jdbc.datasource.SimpleDriverDataSource) Test(org.junit.jupiter.api.Test)

Aggregations

SimpleDriverDataSource (org.springframework.jdbc.datasource.SimpleDriverDataSource)20 Bean (org.springframework.context.annotation.Bean)8 Test (org.junit.jupiter.api.Test)6 Driver (java.sql.Driver)3 ProcessEngineFactoryBean (org.activiti.spring.ProcessEngineFactoryBean)3 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)3 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)3 Properties (java.util.Properties)2 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 Connection (java.sql.Connection)1 Statement (java.sql.Statement)1 DataSource (javax.sql.DataSource)1 SpringLiquibase (liquibase.integration.spring.SpringLiquibase)1 SneakyThrows (lombok.SneakyThrows)1 lombok.val (lombok.val)1 ProcessEngineFactoryBean (org.camunda.bpm.engine.spring.ProcessEngineFactoryBean)1 Flyway (org.flywaydb.core.Flyway)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1 EmbeddedDatabase (org.springframework.jdbc.datasource.embedded.EmbeddedDatabase)1