org.jooq.impl.DataSourceConnectionProvider Java Examples

The following examples show how to use org.jooq.impl.DataSourceConnectionProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DatabaseModule.java    From curiostack with MIT License 6 votes vote down vote up
@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))
          .set(DatabaseUtil.sfmRecordMapperProvider());
  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;
}
 
Example #2
Source File: JooqConfig.java    From StubbornJava with MIT License 5 votes vote down vote up
public static Configuration defaultConfigFromDataSource(DataSource ds) {
    DataSourceConnectionProvider dcp = new DataSourceConnectionProvider(ds);
    Configuration jooqConfig = new DefaultConfiguration();
    jooqConfig.set(SQLDialect.MYSQL);
    jooqConfig.set(dcp);
    //jooqConfig.set(new ThreadLocalTransactionProvider(dcp));
    jooqConfig.settings()
              .withExecuteWithOptimisticLockingExcludeUnversioned(true);
    return jooqConfig;
}
 
Example #3
Source File: UserDataSources.java    From secrets-proxy with Apache License 2.0 5 votes vote down vote up
private DSLContext getDslContext(PlatformTransactionManager txManager, DataSource dataSource) {
  DefaultConfiguration config = new DefaultConfiguration();
  config.set(new DataSourceConnectionProvider(new TransactionAwareDataSourceProxy(dataSource)));
  config.set(new DefaultExecuteListenerProvider(new JooqExceptionTranslator()));
  config.set(new SpringTransactionProvider(txManager));
  return new DefaultDSLContext(config);
}
 
Example #4
Source File: JooqConfig.java    From StubbornJava with MIT License 5 votes vote down vote up
public static Configuration defaultConfigFromDataSource(DataSource ds) {
    DataSourceConnectionProvider dcp = new DataSourceConnectionProvider(ds);
    Configuration jooqConfig = new DefaultConfiguration();
    jooqConfig.set(SQLDialect.MYSQL);
    jooqConfig.set(dcp);
    //jooqConfig.set(new ThreadLocalTransactionProvider(dcp));
    jooqConfig.settings()
              .withExecuteWithOptimisticLockingExcludeUnversioned(true);
    return jooqConfig;
}
 
Example #5
Source File: JooqFactory.java    From droptools with Apache License 2.0 5 votes vote down vote up
public Configuration build(Environment environment, PooledDataSourceFactory factory, String name) throws ClassNotFoundException {
    final Settings settings = buildSettings();
    final ManagedDataSource dataSource = factory.build(environment.metrics(), name);
    final SQLDialect dialect = determineDialect(factory, dataSource);
    final ConnectionProvider connectionProvider = new DataSourceConnectionProvider(dataSource);
    final Configuration config = new DefaultConfiguration()
            .set(settings)
            .set(dialect)
            .set(connectionProvider);

    environment.lifecycle().manage(dataSource);

    return config;
}
 
Example #6
Source File: CategoryConfiguration.java    From spring-data-examples with Apache License 2.0 4 votes vote down vote up
@Bean
public DataSourceConnectionProvider connectionProvider() {
	return new DataSourceConnectionProvider(new TransactionAwareDataSourceProxy(dataSource));
}
 
Example #7
Source File: AppConfig.java    From sequenceiq-samples with Apache License 2.0 4 votes vote down vote up
@Bean
public DataSourceConnectionProvider dataSourceConnectionProvider() {
    return new DataSourceConnectionProvider(dataSourceProxy());
}
 
Example #8
Source File: JooqFactoryTest.java    From droptools with Apache License 2.0 4 votes vote down vote up
@Test
public void buildsConfigurationUsingDataSourceFactory() throws Exception {
    Configuration config = factory.build(environment, dataSourceFactory);
    DataSourceConnectionProvider provider = (DataSourceConnectionProvider) config.connectionProvider();
    assertThat(provider.dataSource()).isEqualTo(managedDataSource);
}
 
Example #9
Source File: JooqFactoryTest.java    From droptools with Apache License 2.0 4 votes vote down vote up
@Test
public void buildsConfigurationUsingDataSourceFactoryAndName() throws Exception {
    Configuration config = factory.build(environment, dataSourceFactory, DATASOURCE_NAME);
    DataSourceConnectionProvider provider = (DataSourceConnectionProvider) config.connectionProvider();
    assertThat(provider.dataSource()).isEqualTo(managedDataSource);
}
 
Example #10
Source File: PersistenceContextIntegrationTest.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public DataSourceConnectionProvider connectionProvider() {
    return new DataSourceConnectionProvider(transactionAwareDataSource());
}
 
Example #11
Source File: InitialConfiguration.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public DataSourceConnectionProvider connectionProvider() {
    return new DataSourceConnectionProvider(new TransactionAwareDataSourceProxy(dataSource));
}