use of jnc.platform.win32.Handle in project druid by druid-io.
the class SQLMetadataSegmentPublisher method publishSegment.
@VisibleForTesting
void publishSegment(final String identifier, final String dataSource, final String createdDate, final String start, final String end, final boolean partitioned, final String version, final boolean used, final byte[] payload) {
try {
final DBI dbi = connector.getDBI();
List<Map<String, Object>> exists = dbi.withHandle(new HandleCallback<List<Map<String, Object>>>() {
@Override
public List<Map<String, Object>> withHandle(Handle handle) throws Exception {
return handle.createQuery(String.format("SELECT id FROM %s WHERE id=:id", config.getSegmentsTable())).bind("id", identifier).list();
}
});
if (!exists.isEmpty()) {
log.info("Found [%s] in DB, not updating DB", identifier);
return;
}
dbi.withHandle(new HandleCallback<Void>() {
@Override
public Void withHandle(Handle handle) throws Exception {
handle.createStatement(statement).bind("id", identifier).bind("dataSource", dataSource).bind("created_date", createdDate).bind("start", start).bind("end", end).bind("partitioned", partitioned).bind("version", version).bind("used", used).bind("payload", payload).execute();
return null;
}
});
} catch (Exception e) {
log.error(e, "Exception inserting into DB");
throw new RuntimeException(e);
}
}
use of jnc.platform.win32.Handle in project dropwizard by dropwizard.
the class DbMigrateDifferentFileCommandTest method testRun.
@Test
public void testRun() throws Exception {
migrateCommand.run(null, new Namespace(ImmutableMap.of()), conf);
try (Handle handle = new DBI(databaseUrl, "sa", "").open()) {
final List<Map<String, Object>> rows = handle.select("select * from persons");
assertThat(rows).hasSize(0);
}
}
use of jnc.platform.win32.Handle in project Singularity by HubSpot.
the class SingularityHistoryTest method createTestData.
@Before
public void createTestData() throws Exception {
Handle handle = dbiProvider.get().open();
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(handle.getConnection()));
Liquibase liquibase = new Liquibase("singularity_test.sql", new FileSystemResourceAccessor(), database);
liquibase.update((String) null);
try {
database.close();
} catch (Throwable t) {
}
handle.close();
}
use of jnc.platform.win32.Handle in project pac4j by pac4j.
the class DbProfileService method execute.
protected void execute(final String query, final Object... args) {
Handle h = null;
try {
h = dbi.open();
logger.debug("Execute query: {} and values: {}", query, args);
h.execute(query, args);
} finally {
if (h != null) {
h.close();
}
}
}
use of jnc.platform.win32.Handle in project pac4j by pac4j.
the class DbProfileServiceTests method getData.
private List<Map<String, Object>> getData(final int id) {
final DBI dbi = new DBI(ds);
Handle h = null;
try {
h = dbi.open();
return h.createQuery("select id,username,linkedid,password,serializedprofile from users where id = :id").bind("id", id).list(2);
} finally {
if (h != null) {
h.close();
}
}
}
Aggregations