use of org.apache.commons.dbcp.BasicDataSource in project gocd by gocd.
the class H2Database method upgrade.
public void upgrade() throws SQLException {
BasicDataSource source = createDataSource(Boolean.FALSE);
if (systemEnvironment.inDbDebugMode()) {
LOG.info("In debug mode - not upgrading database");
// don't upgrade
} else {
Migration migrateSchema = new DbDeployMigration(source, systemEnvironment);
migrateSchema.migrate();
}
shutdown();
}
use of org.apache.commons.dbcp.BasicDataSource in project gocd by gocd.
the class BackupServiceH2IntegrationTest method constructTestDataSource.
private BasicDataSource constructTestDataSource(File file) {
BasicDataSource source = new BasicDataSource();
source.setDriverClassName("org.h2.Driver");
source.setUrl("jdbc:h2:" + file.getAbsolutePath() + "/cruise;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE");
source.setUsername("sa");
source.setPassword("");
source.setMaxActive(32);
source.setMaxIdle(32);
return source;
}
use of org.apache.commons.dbcp.BasicDataSource in project gocd by gocd.
the class BackupServiceH2IntegrationTest method shouldPerformDbBackupProperly.
@Test
@RunIf(value = DatabaseChecker.class, arguments = { DatabaseChecker.H2 })
public void shouldPerformDbBackupProperly() throws SQLException, IOException {
Pipeline expectedPipeline = saveAPipeline();
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
backupService.startBackup(admin, result);
assertThat(result.isSuccessful(), is(true));
assertThat(result.message(localizer), is("Backup completed successfully."));
String location = temporaryFolder.newFolder().getAbsolutePath();
Restore.execute(dbZip(), location, "cruise", false);
BasicDataSource source = constructTestDataSource(new File(location));
ResultSet resultSet = source.getConnection().prepareStatement("select * from pipelines where id = " + expectedPipeline.getId()).executeQuery();
int size = 0;
while (resultSet.next()) {
assertThat(resultSet.getString("name"), is(expectedPipeline.getName()));
size++;
}
assertThat(size, is(1));
}
use of org.apache.commons.dbcp.BasicDataSource in project kylo by Teradata.
the class JiraSpringTestConfig method dataSource.
@Bean
public DataSource dataSource() {
BasicDataSource dataSource = new BasicDataSource();
dataSource.setUrl("jdbc:mysql://localhost:3306/pipeline_db");
dataSource.setUsername("root");
dataSource.setDriverClassName("org.mariadb.jdbc.Driver");
// dataSource.setPassword("password");
return dataSource;
}
use of org.apache.commons.dbcp.BasicDataSource in project pentaho-kettle by pentaho.
the class ConnectionPoolUtil method addPoolableDataSource.
/**
* This methods adds a new data source to cache
*
* @param log
* @param databaseMeta
* @param partitionId
* @param initialSize
* @param maximumSize
* @throws KettleDatabaseException
*/
private static void addPoolableDataSource(LogChannelInterface log, DatabaseMeta databaseMeta, String partitionId, int initialSize, int maximumSize) throws KettleDatabaseException {
if (log.isBasic()) {
log.logBasic(BaseMessages.getString(PKG, "Database.CreatingConnectionPool", databaseMeta.getName()));
}
BasicDataSource ds = new BasicDataSource();
configureDataSource(ds, databaseMeta, partitionId, initialSize, maximumSize);
// check if datasource is valid
testDataSource(ds);
// register data source
dataSources.put(getDataSourceName(databaseMeta, partitionId), ds);
if (log.isBasic()) {
log.logBasic(BaseMessages.getString(PKG, "Database.CreatedConnectionPool", databaseMeta.getName()));
}
}
Aggregations