use of com.linkedin.thirdeye.datalayer.ScriptRunner in project pinot by linkedin.
the class AbstractManagerTestBase method initializeDs.
private void initializeDs(PersistenceConfig configuration) throws Exception {
ds = new DataSource();
dbUrlId = configuration.getDatabaseConfiguration().getUrl() + System.currentTimeMillis() + "" + Math.random();
ds.setUrl(dbUrlId);
System.out.println("Creating db with connection url : " + ds.getUrl());
ds.setPassword(configuration.getDatabaseConfiguration().getPassword());
ds.setUsername(configuration.getDatabaseConfiguration().getUser());
ds.setDriverClassName(configuration.getDatabaseConfiguration().getProperties().get("hibernate.connection.driver_class"));
// pool size configurations
ds.setMaxActive(200);
ds.setMinIdle(10);
ds.setInitialSize(10);
// when returning connection to pool
ds.setTestOnReturn(true);
ds.setRollbackOnReturn(true);
// Timeout before an abandoned(in use) connection can be removed.
ds.setRemoveAbandonedTimeout(600_000);
ds.setRemoveAbandoned(true);
Connection conn = ds.getConnection();
// create schema
URL createSchemaUrl = getClass().getResource("/schema/create-schema.sql");
ScriptRunner scriptRunner = new ScriptRunner(conn, false, false);
scriptRunner.setDelimiter(";", true);
scriptRunner.runScript(new FileReader(createSchemaUrl.getFile()));
}
use of com.linkedin.thirdeye.datalayer.ScriptRunner in project pinot by linkedin.
the class AbstractManagerTestBase method cleanUpJDBC.
private void cleanUpJDBC() throws Exception {
System.out.println("Cleaning database: start");
try (Connection conn = ds.getConnection()) {
URL deleteSchemaUrl = getClass().getResource("/schema/drop-tables.sql");
ScriptRunner scriptRunner = new ScriptRunner(conn, false, false);
scriptRunner.runScript(new FileReader(deleteSchemaUrl.getFile()));
}
new File(dbUrlId).delete();
System.out.println("Cleaning database: done!");
}
use of com.linkedin.thirdeye.datalayer.ScriptRunner in project pinot by linkedin.
the class TestDBResources method cleanUpJDBC.
private void cleanUpJDBC() throws Exception {
System.out.println("Cleaning database: start");
try (Connection conn = ds.getConnection()) {
URL deleteSchemaUrl = getClass().getResource("/schema/drop-tables.sql");
ScriptRunner scriptRunner = new ScriptRunner(conn, false, false);
scriptRunner.runScript(new FileReader(deleteSchemaUrl.getFile()));
}
System.out.println("Cleaning database: done!");
}
use of com.linkedin.thirdeye.datalayer.ScriptRunner in project pinot by linkedin.
the class TestDBResources method initDB.
private void initDB() throws Exception {
try (Connection conn = ds.getConnection()) {
// create schema
URL createSchemaUrl = getClass().getResource("/schema/create-schema.sql");
ScriptRunner scriptRunner = new ScriptRunner(conn, false, false);
scriptRunner.setDelimiter(";", true);
scriptRunner.runScript(new FileReader(createSchemaUrl.getFile()));
}
}
Aggregations