Java 类org.jooq.conf.Settings 实例源码

项目:AdvancedDataProfilingSeminar    文件:TestDatabase.java   
public void setUp() throws Exception {
  connection = DriverManager.getConnection("jdbc:hsqldb:mem:myDb");
  context = DSL.using(connection, SQLDialect.HSQLDB, new Settings().withRenderNameStyle(
      RenderNameStyle.AS_IS));

  final List<Field<String>> fields = getFields();

  context.createTable(relationName)
      .columns(fields)
      .execute();

  try (InputStream in = resourceClass.getResourceAsStream(csvPath)) {
    final Loader<Record> loader = context.loadInto(table(name(relationName)))
        .loadCSV(in)
        .fields(fields)
        .execute();

    assertThat(loader.errors()).isEmpty();
  }
}
项目:curiostack    文件:DatabaseModule.java   
@Provides
@Singleton
static DSLContext dbContext(
    DataSource dataSource, @ForDatabase ListeningExecutorService dbExecutor) {
  Configuration configuration =
      new DefaultConfiguration()
          .set(dbExecutor)
          .set(SQLDialect.MYSQL)
          .set(new Settings().withRenderSchema(false))
          .set(new DataSourceConnectionProvider(dataSource))
          .set(DatabaseUtil.sfmRecordMapperProvider());
  DSLContext ctx = DSL.using(configuration);
  // Eagerly trigger JOOQ classinit for better startup performance.
  ctx.select().from("curio_server_framework_init").getSQL();
  return ctx;
}
项目:steve-plugsurfing    文件:BeanConfiguration.java   
/**
 * Can we re-use DSLContext as a Spring bean (singleton)? Yes, the Spring tutorial of
 * Jooq also does it that way, but only if we do not change anything about the
 * config after the init (which we don't do anyways) and if the ConnectionProvider
 * does not store any shared state (we use DataSourceConnectionProvider of Jooq, so no problem).
 *
 * Some sources and discussion:
 * - http://www.jooq.org/doc/3.6/manual/getting-started/tutorials/jooq-with-spring/
 * - http://jooq-user.narkive.com/2fvuLodn/dslcontext-and-threads
 * - https://groups.google.com/forum/#!topic/jooq-user/VK7KQcjj3Co
 * - http://stackoverflow.com/questions/32848865/jooq-dslcontext-correct-autowiring-with-spring
 */
@Bean
public DSLContext dslContext() {
    initDataSource();

    Settings settings = new Settings()
            // Normally, the records are "attached" to the Configuration that created (i.e. fetch/insert) them.
            // This means that they hold an internal reference to the same database connection that was used.
            // The idea behind this is to make CRUD easier for potential subsequent store/refresh/delete
            // operations. We do not use or need that.
            .withAttachRecords(false)
            // To log or not to log the sql queries, that is the question
            .withExecuteLogging(CONFIG.getDb().isSqlLogging());

    // Configuration for JOOQ
    org.jooq.Configuration conf = new DefaultConfiguration()
            .set(SQLDialect.MYSQL)
            .set(new DataSourceConnectionProvider(dataSource))
            .set(settings);

    return DSL.using(conf);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JooqAutoConfiguration.java   
public DslContextConfiguration(JooqProperties properties,
        ConnectionProvider connectionProvider,
        ObjectProvider<TransactionProvider> transactionProviderProvider,
        ObjectProvider<RecordMapperProvider> recordMapperProviderProvider,
        ObjectProvider<Settings> settingsProvider,
        ObjectProvider<RecordListenerProvider[]> recordListenerProvidersProvider,
        ExecuteListenerProvider[] executeListenerProviders,
        ObjectProvider<VisitListenerProvider[]> visitListenerProvidersProvider) {
    this.properties = properties;
    this.connectionProvider = connectionProvider;
    this.transactionProvider = transactionProviderProvider.getIfAvailable();
    this.recordMapperProvider = recordMapperProviderProvider.getIfAvailable();
    this.settings = settingsProvider.getIfAvailable();
    this.recordListenerProviders = recordListenerProvidersProvider
            .getIfAvailable();
    this.executeListenerProviders = executeListenerProviders;
    this.visitListenerProviders = visitListenerProvidersProvider.getIfAvailable();
}
项目:spring-boot-concourse    文件:JooqAutoConfiguration.java   
public DslContextConfiguration(JooqProperties properties,
        ConnectionProvider connectionProvider,
        ObjectProvider<TransactionProvider> transactionProviderProvider,
        ObjectProvider<RecordMapperProvider> recordMapperProviderProvider,
        ObjectProvider<Settings> settingsProvider,
        ObjectProvider<RecordListenerProvider[]> recordListenerProvidersProvider,
        ExecuteListenerProvider[] executeListenerProviders,
        ObjectProvider<VisitListenerProvider[]> visitListenerProvidersProvider) {
    this.properties = properties;
    this.connectionProvider = connectionProvider;
    this.transactionProvider = transactionProviderProvider.getIfAvailable();
    this.recordMapperProvider = recordMapperProviderProvider.getIfAvailable();
    this.settings = settingsProvider.getIfAvailable();
    this.recordListenerProviders = recordListenerProvidersProvider
            .getIfAvailable();
    this.executeListenerProviders = executeListenerProviders;
    this.visitListenerProviders = visitListenerProvidersProvider.getIfAvailable();
}
项目:waltz    文件:DIConfiguration.java   
@Bean
@Autowired
public DSLContext dsl(DataSource dataSource) {
    try {
        SQLDialect.valueOf(dialect);
    } catch (IllegalArgumentException iae) {
        System.err.println("Cannot parse sql dialect: "+dialect);
        throw iae;
    }

    Settings dslSettings = null;
    if ("true".equals(System.getProperty(JOOQ_DEBUG_PROPERTY))) {
        dslSettings = new Settings()
                .withRenderFormatted(true)
                .withExecuteLogging(true);
    }

    return DSL.using(
            dataSource,
            SQLDialect.valueOf(dialect),
            dslSettings);
}
项目:high-performance-java-persistence    文件:AbstractJOOQIntegrationTest.java   
protected <T> T doInJOOQ(DSLContextCallable<T> callable, Settings settings) {
    Session session = null;
    Transaction txn = null;
    try {
        session = sessionFactory().openSession();
        txn = session.beginTransaction();
        T result = session.doReturningWork(connection -> {
            DSLContext sql = settings != null ?
                DSL.using(connection, sqlDialect(), settings) :
                DSL.using(connection, sqlDialect());
            return callable.execute(sql);
        });
        txn.commit();
        return result;
    } catch (Throwable e) {
        if ( txn != null ) txn.rollback();
        throw e;
    } finally {
        if (session != null) {
            session.close();
        }
    }
}
项目:high-performance-java-persistence    文件:AbstractJOOQIntegrationTest.java   
protected void doInJOOQ(DSLContextVoidCallable callable, Settings settings) {
    Session session = null;
    Transaction txn = null;
    try {
        session = sessionFactory().openSession();
        txn = session.beginTransaction();
        session.doWork(connection -> {
            DSLContext sql = settings != null ?
                DSL.using(connection, sqlDialect(), settings) :
                DSL.using(connection, sqlDialect());
            callable.execute(sql);
        });
        txn.commit();
    } catch (Throwable e) {
        if ( txn != null ) txn.rollback();
        throw e;
    } finally {
        if (session != null) {
            session.close();
        }
    }
}
项目:cattle    文件:Bootstrap.java   
private void setupDatabase() {
    System.setProperty("org.jooq.no-logo", "true");

    dataSource = dataSourceFactory.createDataSource("cattle");

    DataSourceConnectionProvider dscp = new DataSourceConnectionProvider(dataSource);
    ThreadLocalTransactionProvider tp = new ThreadLocalTransactionProvider(dscp, false);

    LoggerListener logger = new LoggerListener();
    logger.setMaxLength(1000);

    ExecuteListener[] listeners = new ExecuteListener[] { logger, new StopWatchListener() };
    Settings settings = dbSetting("cattle");
    jooqConfig = new DefaultConfiguration()
            .set(getSQLDialect("cattle"))
            .set(settings)
            .set(dscp)
            .set(tp)
            .set(DefaultExecuteListenerProvider.providers(listeners));
}
项目:club-tracker    文件:BrokerTestUtil.java   
static Connector mockConnector(MockDataProvider provider) {
    // Put your provider into a MockConnection and use that connection
    // in your application. In this case, with a jOOQ DSLContext:
    Connection connection = new MockConnection(provider);

    return new Connector() {

        @Override
        public Connection connect() throws SQLException {
            return connection;
        }

        @Override
        public SQLDialect getDialect() {
            return SQLDialect.HSQLDB;
        }

        @Override
        public Settings getSettings() {
            return new Settings();
        }
    };
}
项目:killbill-analytics-plugin    文件:SqlReportDataExtractor.java   
public SqlReportDataExtractor(final String tableName,
                              final ReportSpecification reportSpecification,
                              @Nullable final DateTime startDate,
                              @Nullable final DateTime endDate,
                              final SQLDialect sqlDialect,
                              final Long tenantRecordId) {
    this.tableName = tableName;
    this.reportSpecification = reportSpecification;
    this.startDate = startDate;
    this.endDate = endDate;
    this.tenantRecordId = tenantRecordId;

    final Settings settings = new Settings();
    settings.withStatementType(StatementType.STATIC_STATEMENT);
    settings.withRenderFormatted(true);
    if (SQLDialect.H2.equals(sqlDialect)) {
        settings.withRenderNameStyle(RenderNameStyle.AS_IS);
    }
    this.context = DSL.using(sqlDialect, settings);

    setup();
}
项目:Ultrastructure    文件:WorkspaceSnapshot_ESTest.java   
@Test(timeout = 4000)
public void test05() throws Throwable {
    WorkspaceSnapshot workspaceSnapshot0 = new WorkspaceSnapshot();
    Product product0 = new Product();
    workspaceSnapshot0.definingProduct = product0;
    DefaultConfiguration defaultConfiguration0 = new DefaultConfiguration();
    NoConnectionProvider noConnectionProvider0 = (NoConnectionProvider) defaultConfiguration0.connectionProvider();
    SQLDialect sQLDialect0 = SQLDialect.SQLITE;
    Settings settings0 = new Settings();
    DefaultDSLContext defaultDSLContext0 = new DefaultDSLContext(noConnectionProvider0,
                                                                 sQLDialect0,
                                                                 settings0);
    // Undeclared exception!
    try {
        workspaceSnapshot0.loadDefiningProduct(defaultDSLContext0);
        fail("Expecting exception: RuntimeException");

    } catch (RuntimeException e) {
        //
        // Cannot execute query. No Connection configured
        //
        assertThrownBy("org.jooq.impl.AbstractQuery", e);
    }
}
项目:Ultrastructure    文件:WorkspaceSnapshot_ESTest.java   
@Test(timeout = 4000)
public void test13() throws Throwable {
    UUID uUID0 = new UUID(948L, 0L);
    SQLDialect sQLDialect0 = SQLDialect.CUBRID;
    Settings settings0 = new Settings();
    DefaultDSLContext defaultDSLContext0 = new DefaultDSLContext((DataSource) null,
                                                                 sQLDialect0,
                                                                 settings0);
    // Undeclared exception!
    try {
        WorkspaceSnapshot.getAuthorizations(uUID0, defaultDSLContext0);
        fail("Expecting exception: NullPointerException");

    } catch (NullPointerException e) {
        //
        // no message in exception (getMessage() returned null)
        //
        assertThrownBy("org.jooq.impl.DataSourceConnectionProvider", e);
    }
}
项目:Ultrastructure    文件:WorkspaceSnapshot_ESTest.java   
@Test(timeout = 4000)
public void test18() throws Throwable {
    Product product0 = new Product();
    PGPoolingDataSource pGPoolingDataSource0 = PGPoolingDataSource.getDataSource("");
    SQLDialect sQLDialect0 = SQLDialect.MARIADB;
    Settings settings0 = new Settings();
    DefaultDSLContext defaultDSLContext0 = new DefaultDSLContext(pGPoolingDataSource0,
                                                                 sQLDialect0,
                                                                 settings0);
    try {
        new WorkspaceSnapshot(product0, defaultDSLContext0);
        fail("Expecting exception: NullPointerException");

    } catch (NullPointerException e) {
        //
        // no message in exception (getMessage() returned null)
        //
        assertThrownBy("org.jooq.impl.DataSourceConnectionProvider", e);
    }
}
项目:Ultrastructure    文件:WorkspaceSnapshot_ESTest.java   
@Test(timeout = 4000)
public void test22() throws Throwable {
    WorkspaceSnapshot workspaceSnapshot0 = new WorkspaceSnapshot();
    Jdbc3SimpleDataSource jdbc3SimpleDataSource0 = new Jdbc3SimpleDataSource();
    DataSourceConnectionProvider dataSourceConnectionProvider0 = new DataSourceConnectionProvider(jdbc3SimpleDataSource0);
    SQLDialect sQLDialect0 = SQLDialect.FIREBIRD;
    Settings settings0 = new Settings();
    DefaultDSLContext defaultDSLContext0 = new DefaultDSLContext(dataSourceConnectionProvider0,
                                                                 sQLDialect0,
                                                                 settings0);
    // Undeclared exception!
    try {
        workspaceSnapshot0.load(defaultDSLContext0);
        fail("Expecting exception: NullPointerException");

    } catch (NullPointerException e) {
        //
        // no message in exception (getMessage() returned null)
        //
        assertThrownBy("com.chiralbehaviors.CoRE.workspace.WorkspaceSnapshot",
                       e);
    }
}
项目:Ultrastructure    文件:WorkspaceSnapshot_ESTest.java   
@Test(timeout = 4000)
public void test23() throws Throwable {
    SQLDialect sQLDialect0 = SQLDialect.SQLITE;
    DefaultDSLContext defaultDSLContext0 = new DefaultDSLContext((DataSource) null,
                                                                 sQLDialect0,
                                                                 (Settings) null);
    Product product0 = new Product();
    // Undeclared exception!
    try {
        WorkspaceSnapshot.selectWorkspaceClosure(defaultDSLContext0,
                                                 product0);
        fail("Expecting exception: NullPointerException");

    } catch (NullPointerException e) {
        //
        // no message in exception (getMessage() returned null)
        //
        assertThrownBy("org.jooq.impl.DataSourceConnectionProvider", e);
    }
}
项目:steve    文件:BeanConfiguration.java   
/**
 * Can we re-use DSLContext as a Spring bean (singleton)? Yes, the Spring tutorial of
 * Jooq also does it that way, but only if we do not change anything about the
 * config after the init (which we don't do anyways) and if the ConnectionProvider
 * does not store any shared state (we use DataSourceConnectionProvider of Jooq, so no problem).
 *
 * Some sources and discussion:
 * - http://www.jooq.org/doc/3.6/manual/getting-started/tutorials/jooq-with-spring/
 * - http://jooq-user.narkive.com/2fvuLodn/dslcontext-and-threads
 * - https://groups.google.com/forum/#!topic/jooq-user/VK7KQcjj3Co
 * - http://stackoverflow.com/questions/32848865/jooq-dslcontext-correct-autowiring-with-spring
 */
@Bean
public DSLContext dslContext() {
    initDataSource();

    Settings settings = new Settings()
            // Normally, the records are "attached" to the Configuration that created (i.e. fetch/insert) them.
            // This means that they hold an internal reference to the same database connection that was used.
            // The idea behind this is to make CRUD easier for potential subsequent store/refresh/delete
            // operations. We do not use or need that.
            .withAttachRecords(false)
            // To log or not to log the sql queries, that is the question
            .withExecuteLogging(CONFIG.getDb().isSqlLogging());

    // Configuration for JOOQ
    org.jooq.Configuration conf = new DefaultConfiguration()
            .set(SQLDialect.MYSQL)
            .set(new DataSourceConnectionProvider(dataSource))
            .set(settings);

    return DSL.using(conf);
}
项目:bootique-jooq    文件:DefaultJooqFactoryFactory.java   
public DefaultJooqFactory createFactory(DataSourceFactory dataSourceFactory) {

        // pretty evil side effect on system properties. Wish Jooq had abstracted its properties bootstrap.
        // Still the logo has to go.
        System.setProperty("org.jooq.no-logo", "true");

        Settings defaultSettings = SettingsTools.defaultSettings();
        defaultSettings.setExecuteLogging(executeLogging);

        // TODO: guess the dialect based on the connection info - https://github.com/bootique/bootique-jooq/issues/3
        Objects.requireNonNull(dialect);

        return new DefaultJooqFactory(dataSourceFactory, dialect, defaultSettings);
    }
项目:hmftools    文件:DatabaseAccess.java   
@Nullable
private Settings settings(final String catalog) {
    return !catalog.equals(DEV_CATALOG)
            ? new Settings().withRenderMapping(new RenderMapping().withSchemata(new MappedSchema().withInput("hmfpatients")
            .withOutput(catalog)))
            : null;
}
项目:java-persistence-frameworks-comparison    文件:DbTestsApplication.java   
@Bean
@Primary
public Settings jooqSettings() {
    Settings ret = new Settings();
    ret.withRenderSchema(false);
    ret.setRenderFormatted(true);

    ret.setRenderNameStyle(RenderNameStyle.AS_IS);
    return ret;
}
项目:java-persistence-frameworks-comparison    文件:DbTestsApplication.java   
@Bean
@Qualifier("static-statement-jooq-settings")
public Settings jooqStaticStatementSettings() {
    Settings ret = jooqSettings();
    ret.withStatementType(StatementType.STATIC_STATEMENT);
    return ret;
}
项目:polygene-java    文件:SQLEntityStoreMixin.java   
@Override
public void activateService() throws Exception
{
    configuration.refresh();
    SQLEntityStoreConfiguration config = configuration.get();

    // Prepare jooq DSL
    SQLDialect dialect = descriptor.metaInfo( SQLDialect.class );
    Settings settings = descriptor.metaInfo( Settings.class );
    String schemaName = config.schemaName().get();
    String tableName = config.entityTableName().get();
    schema = DSL.schema( DSL.name( schemaName ) );
    table = DSL.table(
        dialect.equals( SQLDialect.SQLITE )
        ? DSL.name( tableName )
        : DSL.name( schema.getName(), tableName )
    );
    identityColumn = DSL.field( DSL.name( IDENTITY_COLUMN_NAME ), String.class );
    versionColumn = DSL.field( DSL.name( VERSION_COLUMN_NAME ), String.class );
    stateColumn = DSL.field( DSL.name( STATE_COLUMN_NAME ), String.class );
    dsl = DSL.using( dataSource, dialect, settings );

    // Eventually create schema and apply Liquibase changelog
    if( config.createIfMissing().get() )
    {
        if( !dialect.equals( SQLDialect.SQLITE )
            && dsl.meta().getSchemas().stream().noneMatch( s -> schema.getName().equalsIgnoreCase( s.getName() ) ) )
        {
            dsl.createSchema( schema ).execute();
        }

        applyLiquibaseChangelog( dialect );
    }
}
项目:polygene-java    文件:AbstractSQLEntityStoreAssembler.java   
@Override
public void assemble( ModuleAssembly module )
{
    super.assemble( module );
    SQLDialect dialect = getSQLDialect();
    if( dialect == null )
    {
        throw new AssemblyException( "SQLDialect must not be null" );
    }
    Settings settings = getSettings();
    if( settings == null )
    {
        throw new AssemblyException( "Settings must not be null" );
    }

    String identity = ( hasIdentity() ? identity() : DEFAULT_ENTITYSTORE_IDENTITY ).toString();

    LiquibaseAssembler liquibase = new LiquibaseAssembler().identifiedBy( identity + "-liquibase" );
    if( hasConfig() )
    {
        liquibase.withConfig( configModule(), configVisibility() );
        LiquibaseConfiguration liquibaseconfig = configModule().forMixin( LiquibaseConfiguration.class )
                                                               .declareDefaults();
        liquibaseconfig.changeLog().set( changelogPath );
    }
    liquibase.assemble( module );

    module.services( SQLEntityStoreService.class )
          .identifiedBy( identity )
          .visibleIn( visibility() )
          .setMetaInfo( dialect )
          .setMetaInfo( settings );

    if( hasConfig() )
    {
        configModule().entities( SQLEntityStoreConfiguration.class ).visibleIn( configVisibility() );
    }
}
项目:keywhiz    文件:DSLContexts.java   
public static DSLContext databaseAgnostic(DataSource dataSource) throws SQLException {
SQLDialect dialect;
try (Connection conn = dataSource.getConnection()) {
  dialect = dialect(conn);

  // See https://github.com/jOOQ/jOOQ/issues/4730
  if (conn.getMetaData().getURL().startsWith("jdbc:pgsql:")) {
    dialect = POSTGRES;
  }
}
return DSL.using(dataSource, dialect,
        new Settings()
            .withRenderSchema(false)
            .withRenderNameStyle(RenderNameStyle.AS_IS));
}
项目:BroadwickTutorial    文件:SIRObserverImpl.java   
private Collection getAnimalsThatHaveDied(int time, int increment) {
    String dbName = "sir_model_db"; // change this to demo version
    DatabaseImpl dbImpl = new H2Database(dbName, false);
    //Connection connection = dbImpl.getConnection();
    final Settings settings = new Settings();
    settings.setExecuteLogging(Boolean.FALSE);
    try {
        jooq = DSL.using(dbImpl.getConnection(), dbImpl.getDialect(), settings);
    } catch (SQLException ex) {
        Logger.getLogger(SIRObserverImpl.class.getName()).log(Level.SEVERE, null, ex);
    }
    final Collection<String> animals = new HashSet<>();
    final String whereClause = String.format("%s >= %d and %s <= %d",
            PopulationsFileReader.getDATE_OF_DEATH(), time,
            PopulationsFileReader.getDATE_OF_DEATH(), time + increment);
    final Result<Record> records = jooq.select().from(PopulationsFileReader.getLIFE_HISTORIES_TABLE_NAME()).where(whereClause)
            .fetch();
    for (Record r : records) {
        String id = "";
        id = (String) r.getValue(PopulationsFileReader.getID());
        if (!id.equals("")) {
            animals.add(id);
        }
    }
    log.debug("Found {} animals.", animals.size());
    return animals;
}
项目:BroadwickTutorial    文件:SIRObserverImpl.java   
private Collection getAnimalsThatHaveDied(int time, int increment) {
    String dbName = "sir_model_db"; // change this to demo version
    DatabaseImpl dbImpl = new H2Database(dbName, false);
    //Connection connection = dbImpl.getConnection();
    final Settings settings = new Settings();
    settings.setExecuteLogging(Boolean.FALSE);
    try {
        jooq = DSL.using(dbImpl.getConnection(), dbImpl.getDialect(), settings);
    } catch (SQLException ex) {
        Logger.getLogger(SIRObserverImpl.class.getName()).log(Level.SEVERE, null, ex);
    }
    final Collection<String> animals = new HashSet<>();
    final String whereClause = String.format("%s >= %d and %s <= %d",
            PopulationsFileReader.getDATE_OF_DEATH(), time,
            PopulationsFileReader.getDATE_OF_DEATH(), time + increment);
    final Result<Record> records = jooq.select().from(PopulationsFileReader.getLIFE_HISTORIES_TABLE_NAME()).where(whereClause)
            .fetch();
    for (Record r : records) {
        String id = "";
        id = (String) r.getValue(PopulationsFileReader.getID());
        if (!id.equals("")) {
            animals.add(id);
        }
    }
    log.debug("Found {} animals.", animals.size());
    return animals;
}
项目:jooq-with-liquibase    文件:App.java   
public static void main(String[] args) {
    SQLDialect sqlDialect = args.length == 0 ? SQLDialect.HSQLDB : SQLDialect.POSTGRES; // SQLDialect.ORACLE

    Settings settings = new Settings()
        .withRenderFormatted(true)
        .withRenderSchema(TRUE)
        .withRenderNameStyle(RenderNameStyle.UPPER);
    if (sqlDialect == SQLDialect.POSTGRES) {
        String schema1Name = args[0];
        String schema2Name = args[1];
        settings.withRenderMapping(new RenderMapping()
            .withSchemata(
                new MappedSchema().withInput(SCHEMA1.getName()).withOutput(schema1Name),
                new MappedSchema().withInput(SCHEMA2.getName()).withOutput(schema2Name)));
    }

    Configuration config = new DefaultConfiguration()
        .set(sqlDialect)
        .set(settings);

    Configuration configuration = config;
    DSLContext dsl = DSL.using(configuration);

    System.out.println(
        dsl.select(A.ID, A.FLAG)
            .from(A)
            .join(B).on(B.NAME.eq(A.NAME))
            .toString());
}
项目:cattle    文件:Bootstrap.java   
private static Settings dbSetting(String name) {
    String prop = "db." + name + ".database";
    String database = ArchaiusUtil.getString(prop).get();

    Settings settings = new Settings();
    settings.setRenderSchema(false);
    settings.setExecuteLogging(false);

    String renderNameStyle = ArchaiusUtil.getString("db." + name + "." + database + ".render.name.style").get();
    if (renderNameStyle != null) {
        settings.setRenderNameStyle(RenderNameStyle.valueOf(renderNameStyle.trim().toUpperCase()));
    }

    return settings;
}
项目:club-tracker    文件:ConfiguredConnector.java   
@Override
public Settings getSettings() {
    if(dialect == SQLDialect.POSTGRES) {
        return new Settings().withRenderNameStyle(RenderNameStyle.LOWER);
    }
    return updateSchema(dialect).map(s ->
            new Settings()
                    .withRenderNameStyle(RenderNameStyle.LOWER)
                    .withRenderMapping(new RenderMapping()
                    .withSchemata(
                        new MappedSchema().withInput(Club.CLUB.getName())
                                .withOutput(s))))
                .orElseGet(Settings::new);
}
项目:dstack    文件:Configuration.java   
@PostConstruct
public void init() {
    String prop = "db." + name + ".database";
    String database = ArchaiusUtil.getString(prop).get();
    if ( database == null ) {
        throw new IllegalStateException("Failed to find config for [" + prop + "]");
    }

    try {
        SQLDialect dialect = SQLDialect.valueOf(database.trim().toUpperCase());
        set(dialect);
    } catch ( IllegalArgumentException e ) {
        throw new IllegalArgumentException("Invalid SQLDialect [" + database.toUpperCase() + "]", e);
    }

    if ( connectionProvider == null ) {
        set(new AutoCommitConnectionProvider(dataSource));
    } else {
        set(connectionProvider);
    }

    Settings settings = new Settings();
    settings.setRenderSchema(false);

    String renderNameStyle = ArchaiusUtil.getString("db." + name + "." + database + ".render.name.style").get();
    if ( renderNameStyle != null ) {
        settings.setRenderNameStyle(RenderNameStyle.valueOf(renderNameStyle.trim().toUpperCase()));
    }

    set(settings);

    if ( listeners != null && listeners.size() > 0 ) {
        settings().setExecuteLogging(false);
        set(DefaultExecuteListenerProvider.providers(listeners.toArray(new ExecuteListener[listeners.size()])));
    }
}
项目:AdvancedDataProfilingSeminar    文件:DSLContextFactory.java   
private DSLContext hsqldb(final Connection connection) {
  final Settings settings = new Settings().withRenderNameStyle(RenderNameStyle.AS_IS);
  return DSL.using(connection, SQLDialect.HSQLDB, settings);
}
项目:ninja-jooq    文件:NinjaJooqLifecycle.java   
/**
 * This method reads the configuration properties from
 * your application.conf file and configures jOOQ accordingly.
 * 
 */
public final void startServer(){
    logger.info("Starting jOOQ Module.");

    // Setup basic parameters
    boolean renderSchema = ninjaProperties.getBooleanWithDefault(JOOQ_RENDER_SCHEMA, true);

    //renderMapping

    String renderNameStyleString = ninjaProperties.getWithDefault(JOOQ_RENDER_NAME_STYLE, "QUOTED");
    RenderNameStyle renderNameStyle = RenderNameStyle.fromValue(renderNameStyleString);
    String renderKeywordStyleString = ninjaProperties.getWithDefault(JOOQ_RENDER_KEYWORD_STYLE, "LOWER");
    RenderKeywordStyle renderKeywordStyle = RenderKeywordStyle.valueOf(renderKeywordStyleString);

    boolean renderFormatted = ninjaProperties.getBooleanWithDefault(JOOQ_RENDER_FORMATTED, false);

    String statementTypeString = ninjaProperties.getWithDefault(JOOQ_STATEMENT_TYPE, "PREPARED_STATEMENT");
    StatementType statementType = StatementType.valueOf(statementTypeString);

    boolean executeLogging = ninjaProperties.getBooleanWithDefault(JOOQ_EXECUTE_LOGGING, true);

    // Execute listeners

    boolean executeWithOptimisticLocking = ninjaProperties
            .getBooleanWithDefault(JOOQ_EXECUTE_WITH_OPTIMISTIC_LOCKING, true);

    boolean attachRecords = ninjaProperties.getBooleanWithDefault(JOOQ_ATTACH_RECORDS, true);

    String sqlDialectString = ninjaProperties.getWithDefault(JOOQ_SQL_DIALECT, "DEFAULT");
    SQLDialect sqlDialect = SQLDialect.valueOf(sqlDialectString);

    Settings settings = new Settings();
    settings.setRenderSchema(renderSchema);
    settings.setRenderNameStyle(renderNameStyle);
    settings.setRenderKeywordStyle(renderKeywordStyle);
    settings.setRenderFormatted(renderFormatted);
    settings.setStatementType(statementType);
    settings.setExecuteLogging(executeLogging);
    settings.setExecuteWithOptimisticLocking(executeWithOptimisticLocking);
    settings.setAttachRecords(attachRecords);

    String connectionUrl = ninjaProperties.getOrDie(NinjaConstant.DB_CONNECTION_URL);
    String connectionUsername = ninjaProperties.getOrDie(NinjaConstant.DB_CONNECTION_USERNAME);
    String connectionPassword = ninjaProperties.getWithDefault(NinjaConstant.DB_CONNECTION_PASSWORD, "");

    BasicDataSource connectionPool = new BasicDataSource();

    connectionPool.setUrl(connectionUrl);
    connectionPool.setUsername(connectionUsername);
    connectionPool.setPassword(connectionPassword);

    Configuration configuration = new DefaultConfiguration();
    configuration.set(sqlDialect);
    configuration.set(settings);
    configuration.set(connectionPool);

    dslContext = DSL.using(configuration);
}
项目:bootique-jooq    文件:DefaultJooqFactory.java   
public DefaultJooqFactory(DataSourceFactory dataSourceFactory, SQLDialect dialect, Settings defaultSettings) {
    this.dataSourceFactory = dataSourceFactory;
    this.dialect = Objects.requireNonNull(dialect);
    this.defaultSettings = defaultSettings;
}
项目:zipkin    文件:DSLContexts.java   
DSLContexts(Settings settings, @Nullable ExecuteListenerProvider listenerProvider) {
  this.settings = checkNotNull(settings, "settings");
  this.listenerProvider = listenerProvider;
}
项目:MBaaS    文件:ConfigurationFactoryBean.java   
@Override
    public void afterPropertiesSet() throws Exception {
        com.angkorteam.mbaas.server.bean.Configuration xml = null;
        String configurationFile = this.servletContext.getInitParameter("configuration");
        File file;
        if (!Strings.isNullOrEmpty(configurationFile)) {
            file = new File(configurationFile);
        } else {
            File home = new File(java.lang.System.getProperty("user.home"));
            file = new File(home, ".xml/" + com.angkorteam.mbaas.server.bean.Configuration.KEY);
        }
        try {
            xml = new com.angkorteam.mbaas.server.bean.Configuration(file);
        } catch (ConfigurationException e) {
        }

        MappedSchema mappedSchema = new MappedSchema();
        mappedSchema.withInput(xml.getString(com.angkorteam.mbaas.server.bean.Configuration.TEMP_JDBC_DATABASE));
        String itest = java.lang.System.getProperty("itest");
        if (itest == null || "".equals(itest)) {
            mappedSchema.withOutput(xml.getString(com.angkorteam.mbaas.server.bean.Configuration.APP_JDBC_DATABASE));
        } else {
            mappedSchema.withOutput(xml.getString(com.angkorteam.mbaas.server.bean.Configuration.TEST_JDBC_DATABASE));
        }
        RenderMapping renderMapping = new RenderMapping();
        renderMapping.withSchemata(mappedSchema);
        Settings settings = new Settings();
        settings.withRenderMapping(renderMapping);
        settings.withExecuteWithOptimisticLocking(true);
        settings.setUpdatablePrimaryKeys(false);

        DefaultConfiguration configuration = new DefaultConfiguration();
        configuration.setSettings(settings);
        configuration.setDataSource(this.dataSource);
        configuration.set(SQLDialect.MYSQL);
//        if ("com.mysql.cj.jdbc.Driver".equals(dataSource.getDriverClassName())) {
//            configuration.set(SQLDialect.MYSQL);
//        } else if ("com.mysql.jdbc.Driver".equals(dataSource.getDriverClassName())) {
//            configuration.set(SQLDialect.MYSQL);
//        } else if ("org.hsqldb.jdbcDriver".equals(dataSource.getDriverClassName())) {
//            configuration.set(SQLDialect.HSQLDB);
//        } else if ("org.mariadb.jdbc.Driver".equals(dataSource.getDriverClassName())) {
//            configuration.set(SQLDialect.MARIADB);
//        }
        this.configuration = configuration;
    }
项目:java-persistence-frameworks-comparison    文件:JooqDataRepositoryImpl.java   
@SuppressWarnings("SpringJavaAutowiringInspection")
@Autowired
public JooqDataRepositoryImpl(DSLContext create, @Qualifier("static-statement-jooq-settings") Settings staticStatementSettings) {
    this.create = create;
    this.staticStatementSettings = staticStatementSettings;
}
项目:httpQL    文件:SelectBuilder.java   
private SelectFinalStep<?> buildSelect() {
  Select<?> select;
  SelectFromStep<?> selectFrom;
  Settings settings = new Settings();
  settings.setRenderNameStyle(renderNameStyle);
  DSLContext ctx = DSL.using(dialect, settings);
  Table<?> table = getTable();

  if (asCount) {
    if (includedFieldNames.size() > 0) {
      List<Field<?>> distinctFields = fieldNamesToFields();
      selectFrom = ctx.select(DSL.countDistinct(distinctFields.toArray(new Field[distinctFields.size()])));
    } else {
      selectFrom = ctx.selectCount();
    }
  } else {
    SelectSelectStep<?> selectStep;
    if (includedFieldNames.size() > 0) {
      selectStep = ctx.select(fieldNamesToFields());
    } else {
      String tableName = sourceQuery.getBoundQuery().tableName();

      if (joinConditions.size() > 0) {
        selectStep = ctx.selectDistinct(DSL.field(tableName + ".*"));
      } else {
        selectStep = ctx.select(DSL.field("*"));
      }
    }
    if (additionalFields.size() > 0) {
      selectFrom = selectStep.select(additionalFields);
    } else {
      selectFrom = selectStep;
    }
  }
  select = selectFrom.from(table);
  for (JoinCondition joinCondition : joinConditions) {
    if (joinCondition.isLeftJoin()) {
      ((SelectJoinStep<?>) select).leftOuterJoin(joinCondition.getTable()).on(joinCondition.getCondition());
    } else {
      ((SelectJoinStep<?>) select).join(joinCondition.getTable()).on(joinCondition.getCondition());
    }
  }
  select = ((SelectJoinStep<?>) select).where(getConditions());

  if (groupByFields.size() > 0) {
    select = ((SelectJoinStep<?>) select).groupBy(groupByFields);
  }

  if (includeOrderings) {
    select = ((SelectOrderByStep<?>) select).orderBy(orderingsToSortFields());
  }
  if (includeConstraints) {
    if (sourceQuery.getLimit().isPresent()) {
      select = ((SelectLimitStep<?>) select).limit(sourceQuery.getLimit().get());
    }
    if (sourceQuery.getOffset().isPresent()) {
      select = ((SelectOffsetStep<?>) select).offset(sourceQuery.getOffset().get());
    }
  }
  return (SelectFinalStep<?>) select;
}