use of io.dropwizard.jdbi.DBIFactory in project dropwizard by dropwizard.
the class GuavaOptionalLocalDateTimeTest method setupTests.
@Before
public void setupTests() throws IOException {
final DataSourceFactory dataSourceFactory = new DataSourceFactory();
dataSourceFactory.setDriverClass("org.h2.Driver");
dataSourceFactory.setUrl("jdbc:h2:mem:guava-local-date-time-" + System.currentTimeMillis() + "?user=sa");
dataSourceFactory.setInitialSize(1);
final DBI dbi = new DBIFactory().build(env, dataSourceFactory, "test");
try (Handle h = dbi.open()) {
h.execute("CREATE TABLE IF NOT EXISTS tasks (" + "id INT PRIMARY KEY, " + "assignee VARCHAR(255) NOT NULL, " + "start_date TIMESTAMP, " + "end_date TIMESTAMP, " + "comments VARCHAR(1024) " + ")");
}
dao = dbi.onDemand(TaskDao.class);
}
use of io.dropwizard.jdbi.DBIFactory in project dropwizard by dropwizard.
the class GuavaOptionalOffsetDateTimeTest method setupTests.
@Before
public void setupTests() throws IOException {
final DataSourceFactory dataSourceFactory = new DataSourceFactory();
dataSourceFactory.setDriverClass("org.h2.Driver");
dataSourceFactory.setUrl("jdbc:h2:mem:guava-offset-date-time-" + System.currentTimeMillis() + "?user=sa");
dataSourceFactory.setInitialSize(1);
final DBI dbi = new DBIFactory().build(env, dataSourceFactory, "test");
try (Handle h = dbi.open()) {
h.execute("CREATE TABLE IF NOT EXISTS tasks (" + "id INT PRIMARY KEY, " + "assignee VARCHAR(255) NOT NULL, " + "start_date TIMESTAMP, " + "end_date TIMESTAMP, " + "comments VARCHAR(1024) " + ")");
}
dao = dbi.onDemand(TaskDao.class);
}
use of io.dropwizard.jdbi.DBIFactory in project dropwizard by dropwizard.
the class OptionalLongTest method setupTests.
@Before
public void setupTests() throws IOException {
final DataSourceFactory dataSourceFactory = new DataSourceFactory();
dataSourceFactory.setDriverClass("org.h2.Driver");
dataSourceFactory.setUrl("jdbc:h2:mem:optional-long-" + System.currentTimeMillis() + "?user=sa");
dataSourceFactory.setInitialSize(1);
final DBI dbi = new DBIFactory().build(env, dataSourceFactory, "test");
try (Handle h = dbi.open()) {
h.execute("CREATE TABLE test (id INT PRIMARY KEY, optional BIGINT)");
}
dao = dbi.onDemand(TestDao.class);
}
use of io.dropwizard.jdbi.DBIFactory in project airpal by airbnb.
the class AirpalModule method provideDBI.
@Singleton
@Provides
public DBI provideDBI(ObjectMapper objectMapper) throws ClassNotFoundException {
final DBIFactory factory = new DBIFactory();
final DBI dbi = factory.build(environment, config.getDataSourceFactory(), provideDbType().name());
dbi.registerMapper(new TableRow.TableRowMapper(objectMapper));
dbi.registerMapper(new QueryStoreMapper(objectMapper));
dbi.registerArgumentFactory(new UUIDArgumentFactory());
dbi.registerArgumentFactory(new URIArgumentFactory());
return dbi;
}
Aggregations