use of org.jooq.impl.DefaultConfiguration in project waltz by khartec.
the class DIInMemoryTestConfiguration method dsl.
@Bean
@Autowired
public DSLContext dsl(DataSource dataSource) {
Settings dslSettings = new Settings().withRenderFormatted(true).withDebugInfoOnStackTrace(true).withRenderQuotedNames(RenderQuotedNames.ALWAYS).withExecuteLogging(true);
org.jooq.Configuration configuration = new DefaultConfiguration().set(dataSource).set(dslSettings).set(SQLDialect.H2);
return DSL.using(configuration);
}
use of org.jooq.impl.DefaultConfiguration in project curiostack by curioswitch.
the class DatabaseModule method dbContext.
@Provides
@Singleton
static DSLContext dbContext(DataSource dataSource, DatabaseConfig config, @ForDatabase ListeningExecutorService dbExecutor) {
Configuration configuration = new DefaultConfiguration().set(dbExecutor).set(SQLDialect.MYSQL).set(new Settings().withRenderSchema(false)).set(new DataSourceConnectionProvider(dataSource));
if (config.getLogQueries()) {
configuration.set(new QueryLogger());
}
DSLContext ctx = DSL.using(configuration);
// Eagerly trigger JOOQ classinit for better startup performance.
ctx.select().from("curio_server_framework_init").getSQL();
return ctx;
}
use of org.jooq.impl.DefaultConfiguration in project jOOQ by jOOQ.
the class LicenseService method run.
// -------------------------------------------------------------------------
// Utilities
// -------------------------------------------------------------------------
/**
* This method encapsulates a transaction and initialises a jOOQ DSLcontext.
* This could also be achieved with Spring and DBCP for connection pooling.
*/
private String run(CtxRunnable runnable) {
Connection c = null;
try {
Class.forName("org.postgresql.Driver");
c = getConnection("jdbc:postgresql:postgres", "postgres", System.getProperty("pw", "test"));
DSLContext ctx = DSL.using(new DefaultConfiguration().set(new DefaultConnectionProvider(c)).set(SQLDialect.POSTGRES).set(new Settings().withExecuteLogging(false)));
return runnable.run(ctx);
} catch (Exception e) {
e.printStackTrace();
Response.status(Status.SERVICE_UNAVAILABLE);
return "Service Unavailable - Please contact support@datageekery.com for help";
} finally {
JDBCUtils.safeClose(c);
}
}
use of org.jooq.impl.DefaultConfiguration in project jOOQ by jOOQ.
the class Mock method result.
/**
* Wrap a record in a result.
*/
static final Result<?> result(Record data) {
Configuration configuration = data instanceof AttachableInternal ? ((AttachableInternal) data).configuration() : new DefaultConfiguration();
Result<Record> result = using(configuration).newResult(data.fields());
result.add(data);
return result;
}
use of org.jooq.impl.DefaultConfiguration in project SimpleFlatMapper by arnaudroger.
the class Issue318Test method testHsqlDb.
@Test
public void testHsqlDb() throws SQLException {
Connection conn = DbHelper.objectDb();
DSLContext dsl = DSL.using(new DefaultConfiguration().set(conn).set(SQLDialect.HSQLDB).set(SfmRecordMapperProviderFactory.newInstance().ignorePropertyNotFound().newProvider()));
List<Issue318> list = dsl.select().from("issue318").fetchInto(Issue318.class);
assertEquals(1, list.size());
Issue318 value = list.get(0);
assertTrue(Math.abs(value.getT().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() - System.currentTimeMillis()) < 10000);
assertNotNull(value.getId());
}
Aggregations