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;
}
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;
}
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;
}
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;
}
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);
}
}
}
}
Aggregations