use of org.sql2o.Sql2o in project sql2o by aaberg.
the class H2Tests method testIssue155.
@Test
public void testIssue155() {
Sql2o sql2o = new Sql2o(ds, new NoQuirks(new HashMap<Class, Converter>() {
{
put(DateTime.class, new DateTimeConverter(DateTimeZone.getDefault()));
}
}));
assertThat(sql2o.getQuirks(), is(instanceOf(NoQuirks.class)));
try (Connection connection = sql2o.open()) {
int val = connection.createQuery("select 42").executeScalar(Integer.class);
assertThat(val, is(equalTo(42)));
}
}
use of org.sql2o.Sql2o in project sql2o by aaberg.
the class H2Tests method testIssue172NPEWhenCreatingBasicDataSourceInline.
@Test
public void testIssue172NPEWhenCreatingBasicDataSourceInline() {
DataSource ds = new JdbcDataSource() {
{
setURL(url);
setUser(user);
setPassword(pass);
}
};
Sql2o sql2o = new Sql2o(ds);
assertThat(sql2o.getQuirks(), is(instanceOf(H2Quirks.class)));
}
use of org.sql2o.Sql2o in project runelite by runelite.
the class SpringBootWebApplication method cacheSql2o.
@Bean("Runelite Cache SQL2O")
Sql2o cacheSql2o() throws NamingException {
DataSource dataSource = (DataSource) getContext().lookup("jdbc/runelite-cache2");
Map<Class, Converter> converters = new HashMap<>();
converters.put(Instant.class, new InstantConverter());
return new Sql2o(dataSource, new NoQuirks(converters));
}
use of org.sql2o.Sql2o in project runelite by runelite.
the class SpringBootWebApplication method trackerSql2o.
@Bean("Runelite XP Tracker SQL2O")
Sql2o trackerSql2o() throws NamingException {
DataSource dataSource = (DataSource) getContext().lookup("jdbc/runelite-tracker");
Map<Class, Converter> converters = new HashMap<>();
converters.put(Instant.class, new InstantConverter());
return new Sql2o(dataSource, new NoQuirks(converters));
}
use of org.sql2o.Sql2o in project mapping-benchmark by arnaudroger.
the class Sql2OSfmBenchmark method main.
public static void main(String[] args) throws SQLException, NamingException {
ConnectionParam connParam = new ConnectionParam();
connParam.db = DbTarget.H2;
connParam.init();
Sql2o sql2o = new Sql2o(connParam.dataSource);
org.sql2o.Connection conn = sql2o.open();
Map<String, String> columnMappings = new HashMap<>();
columnMappings.put("YEAR_STARTED", "yearStarted");
SfmResultSetHandlerFactoryBuilder builder = new SfmResultSetHandlerFactoryBuilder();
builder.setColumnMappings(columnMappings);
ResultSetHandlerFactory<MappedObject16> factory16 = builder.newFactory(MappedObject16.class);
try {
ResultSetIterable<MappedObject16> resultSetIterable = conn.createQuery(Sql2OBenchmark.SELECT_OBJECT16).addParameter("limit", 2).executeAndFetchLazy(factory16);
for (MappedObject16 o : resultSetIterable) {
System.out.println("o = " + o);
}
} finally {
conn.close();
}
}
Aggregations