Search in sources :

Example 11 with DefaultConfiguration

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);
}
Also used : DefaultConfiguration(org.jooq.impl.DefaultConfiguration) Settings(org.jooq.conf.Settings) Autowired(org.springframework.beans.factory.annotation.Autowired)

Example 12 with DefaultConfiguration

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;
}
Also used : DefaultConfiguration(org.jooq.impl.DefaultConfiguration) Configuration(org.jooq.Configuration) DataSourceConnectionProvider(org.jooq.impl.DataSourceConnectionProvider) DSLContext(org.jooq.DSLContext) DefaultConfiguration(org.jooq.impl.DefaultConfiguration) Settings(org.jooq.conf.Settings) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 13 with DefaultConfiguration

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);
    }
}
Also used : DefaultConnectionProvider(org.jooq.impl.DefaultConnectionProvider) Connection(java.sql.Connection) DriverManager.getConnection(java.sql.DriverManager.getConnection) DSLContext(org.jooq.DSLContext) DefaultConfiguration(org.jooq.impl.DefaultConfiguration) Settings(org.jooq.conf.Settings)

Example 14 with DefaultConfiguration

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;
}
Also used : Configuration(org.jooq.Configuration) DefaultConfiguration(org.jooq.impl.DefaultConfiguration) DefaultConfiguration(org.jooq.impl.DefaultConfiguration) Record(org.jooq.Record) AttachableInternal(org.jooq.AttachableInternal)

Example 15 with DefaultConfiguration

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());
}
Also used : Connection(java.sql.Connection) DefaultConfiguration(org.jooq.impl.DefaultConfiguration) Test(org.junit.Test)

Aggregations

DefaultConfiguration (org.jooq.impl.DefaultConfiguration)27 Settings (org.jooq.conf.Settings)7 Connection (java.sql.Connection)6 Configuration (org.jooq.Configuration)6 DSLContext (org.jooq.DSLContext)6 ConnectionParam (org.simpleflatmapper.db.ConnectionParam)6 Test (org.junit.Test)5 DefaultExecuteListenerProvider (org.jooq.impl.DefaultExecuteListenerProvider)4 SfmRecordMapperProvider (org.simpleflatmapper.jooq.SfmRecordMapperProvider)4 Bean (org.springframework.context.annotation.Bean)4 Properties (java.util.Properties)3 SQLDialect (org.jooq.SQLDialect)3 DataSourceConnectionProvider (org.jooq.impl.DataSourceConnectionProvider)3 DefaultConnectionProvider (org.jooq.impl.DefaultConnectionProvider)3 Provides (dagger.Provides)2 List (java.util.List)2 Singleton (javax.inject.Singleton)2 BasicDataSource (org.apache.commons.dbcp.BasicDataSource)2 ConnectionProvider (org.jooq.ConnectionProvider)2 DbObject (org.simpleflatmapper.test.beans.DbObject)2