Search in sources :

Example 1 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();
    ds.setDriverClass(org.h2.Driver.class);
    // Connection settings
    ds.setUrl("jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000");
    ds.setUsername("sa");
    return ds;
}
Also used : SimpleDriverDataSource(org.springframework.jdbc.datasource.SimpleDriverDataSource) ProcessEngineFactoryBean(org.activiti.spring.ProcessEngineFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with SimpleDriverDataSource

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

the class DatabaseConfiguration method dataSource.

@Bean
public DataSource dataSource() {
    SimpleDriverDataSource ds = new SimpleDriverDataSource();
    ds.setDriverClass(org.h2.Driver.class);
    // Connection settings
    ds.setUrl("jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000");
    ds.setUsername("sa");
    return ds;
}
Also used : SimpleDriverDataSource(org.springframework.jdbc.datasource.SimpleDriverDataSource) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 3 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 4 with SimpleDriverDataSource

use of org.springframework.jdbc.datasource.SimpleDriverDataSource in project cloudbreak by hortonworks.

the class DatabaseConfig method dataSource.

@Bean
public DataSource dataSource() throws SQLException {
    DatabaseUtil.createSchemaIfNeeded("postgresql", databaseAddress, dbName, dbUser, dbPassword, dbSchemaName);
    SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
    dataSource.setDriverClass(Driver.class);
    if (ssl && Files.exists(Paths.get(certFile))) {
        Properties properties = new Properties();
        properties.setProperty("ssl", "true");
        properties.setProperty("sslfactory", "org.postgresql.ssl.SingleCertValidatingFactory");
        properties.setProperty("sslfactoryarg", "file://" + certFile);
        dataSource.setConnectionProperties(properties);
    }
    dataSource.setUrl(String.format("jdbc:postgresql://%s/%s?currentSchema=%s", databaseAddress, dbName, dbSchemaName));
    dataSource.setUsername(dbUser);
    dataSource.setPassword(dbPassword);
    return dataSource;
}
Also used : SimpleDriverDataSource(org.springframework.jdbc.datasource.SimpleDriverDataSource) Properties(java.util.Properties) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 5 with SimpleDriverDataSource

use of org.springframework.jdbc.datasource.SimpleDriverDataSource in project cloudbreak by hortonworks.

the class DatabaseUtil method createSchemaIfNeeded.

public static void createSchemaIfNeeded(String dbType, String dbAddress, String dbName, String dbUser, String dbPassword, String dbSchema) throws SQLException {
    if (!DEFAULT_SCHEMA_NAME.equals(dbSchema)) {
        SimpleDriverDataSource ds = new SimpleDriverDataSource();
        ds.setDriverClass(Driver.class);
        ds.setUrl(String.format("jdbc:%s://%s/%s", dbType, dbAddress, dbName));
        try (Connection conn = ds.getConnection(dbUser, dbPassword)) {
            try (Statement statement = conn.createStatement()) {
                statement.execute("CREATE SCHEMA IF NOT EXISTS " + dbSchema);
            }
        }
    }
}
Also used : Statement(java.sql.Statement) Connection(java.sql.Connection) SimpleDriverDataSource(org.springframework.jdbc.datasource.SimpleDriverDataSource)

Aggregations

SimpleDriverDataSource (org.springframework.jdbc.datasource.SimpleDriverDataSource)13 Bean (org.springframework.context.annotation.Bean)8 ProcessEngineFactoryBean (org.activiti.spring.ProcessEngineFactoryBean)3 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)3 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)3 Driver (java.sql.Driver)2 Properties (java.util.Properties)2 Connection (java.sql.Connection)1 Statement (java.sql.Statement)1 DataSource (javax.sql.DataSource)1 ProcessEngineFactoryBean (org.camunda.bpm.engine.spring.ProcessEngineFactoryBean)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1