本文整理汇总了Java中org.jooq.impl.DefaultConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java DefaultConfiguration类的具体用法?Java DefaultConfiguration怎么用?Java DefaultConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultConfiguration类属于org.jooq.impl包,在下文中一共展示了DefaultConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupDatabase
import org.jooq.impl.DefaultConfiguration; //导入依赖的package包/类
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));
}
示例2: testSave
import org.jooq.impl.DefaultConfiguration; //导入依赖的package包/类
@Test
public void testSave() throws SQLException {
final Configuration jooqConfig = new DefaultConfiguration().set(con).set(SQLDialect.MYSQL);
final News news = insertNews(con, jooqConfig);
// Test now
final NewsTable newsTable = new NewsTable();
final News fetchedNews = DSL.using(jooqConfig).selectFrom(newsTable).where(newsTable.CONTENT_ID.eq(news.getId())).fetchOneInto(News.class);
final ContentTable contentTable = new ContentTable();
final Content fetchedContent = DSL.using(jooqConfig).selectFrom(contentTable).where(contentTable.ID.eq(news.getId())).fetchOneInto(Content.class);
assertNotNull(fetchedNews);
assertNotNull(fetchedContent);
}
示例3: testGet
import org.jooq.impl.DefaultConfiguration; //导入依赖的package包/类
@Test
public void testGet() {
final Configuration jooqConfig = new DefaultConfiguration().set(con).set(SQLDialect.MYSQL);
final News news = insertNews(con, jooqConfig);
final News fetchedNews = new NewsDao(con).getNews(news.getId());
assertNotNull(fetchedNews);
assertEquals(news.getTitle(), fetchedNews.getTitle());
assertEquals(news.getText(), fetchedNews.getText());
assertEquals(news.getProviderId(), fetchedNews.getProviderId());
assertEquals(news.getCategoryId(), fetchedNews.getCategoryId());
assertEquals(news.getLocale(), fetchedNews.getLocale());
assertEquals(news.getLink(), fetchedNews.getLink());
assertEquals(news.getImageUrl(), fetchedNews.getImageUrl());
assertEquals(news.getImageWidth(), fetchedNews.getImageWidth());
assertEquals(news.getImageHeight(), fetchedNews.getImageHeight());
assertEquals(news.getNewsGroupId(), fetchedNews.getNewsGroupId());
}
示例4: initInternal
import org.jooq.impl.DefaultConfiguration; //导入依赖的package包/类
private static void initInternal(final Vertx vertx,
final String name) {
vertxRef = vertx;
Fn.pool(CONFIGS, name,
() -> Infix.init(Plugins.Infix.JOOQ,
(config) -> {
// Initialized client
final Configuration configuration = new DefaultConfiguration();
configuration.set(SQLDialect.MYSQL_8_0);
final ConnectionProvider provider =
new DefaultConnectionProvider(HikariCpPool.getConnection(
config.getJsonObject("provider")
));
// Initialized default configuration
configuration.set(provider);
return configuration;
}, JooqInfix.class));
}
示例5: dbContext
import org.jooq.impl.DefaultConfiguration; //导入依赖的package包/类
@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;
}
示例6: createDDL
import org.jooq.impl.DefaultConfiguration; //导入依赖的package包/类
private String createDDL(DefaultConfiguration config) {
DSLContext create = DSL.using(config);
String ddl = create.alterTable(table("oidc_invitations"))
.renameColumn(field("oidc_sub"))
.to(field("oidc_payload", SQLDataType.CLOB))
.getSQL();
if (create.configuration().dialect() == SQLDialect.MYSQL) {
Matcher m = Pattern.compile("\\s+RENAME\\s+COLUMN\\s+(\\w+)\\s+TO\\s+", Pattern.CASE_INSENSITIVE).matcher(ddl);
StringBuffer sb = new StringBuffer();
if (m.find()) {
m.appendReplacement(sb, " change " + m.group(1) + " ");
m.appendTail(sb);
sb.append(" text not null");
ddl = sb.toString();
}
}
return ddl;
}
示例7: dslContext
import org.jooq.impl.DefaultConfiguration; //导入依赖的package包/类
/**
* 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);
}
示例8: jooqConfiguration
import org.jooq.impl.DefaultConfiguration; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(org.jooq.Configuration.class)
public DefaultConfiguration jooqConfiguration() {
DefaultConfiguration configuration = new DefaultConfiguration();
if (this.properties.getSqlDialect() != null) {
configuration.set(this.properties.getSqlDialect());
}
configuration.set(this.connectionProvider);
if (this.transactionProvider != null) {
configuration.set(this.transactionProvider);
}
if (this.recordMapperProvider != null) {
configuration.set(this.recordMapperProvider);
}
if (this.settings != null) {
configuration.set(this.settings);
}
configuration.set(this.recordListenerProviders);
configuration.set(this.executeListenerProviders);
configuration.set(this.visitListenerProviders);
return configuration;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:23,代码来源:JooqAutoConfiguration.java
示例9: run
import org.jooq.impl.DefaultConfiguration; //导入依赖的package包/类
@Override
public void run(T dwConfiguration, Environment environment) throws Exception {
final DataSourceFactory dbConfig = getDataSourceFactory(dwConfiguration);
ManagedDataSource dataSource = dbConfig.build(environment.metrics(), "jooq");
this.configuration = new DefaultConfiguration();
this.configuration.set(new DataSourceConnectionProvider(dataSource));
configure(this.configuration);
environment.jersey().register(JooqTransactionalApplicationListener.class);
environment.jersey().register(
new ConfigurationFactoryProvider.Binder(this.configuration, dataSource, multiTenantConnectionProvider));
environment.lifecycle().manage(dataSource);
if (multiTenantConnectionProvider != null) {
environment.lifecycle().manage(multiTenantConnectionProvider);
}
environment.healthChecks().register("jooq", new JooqHealthCheck(
DSL.using(this.configuration.derive(new DefaultConnectionProvider(dataSource.getConnection()))),
dbConfig.getValidationQuery()));
}
示例10: jooqConfigs
import org.jooq.impl.DefaultConfiguration; //导入依赖的package包/类
@Provides
@Singleton
Configuration jooqConfigs(Config config) {
HikariConfig hikaryConfig = new HikariConfig();
hikaryConfig.setJdbcUrl(config.get(ConfigConverters.ofString(), "db.jdbcUrl"));
hikaryConfig.setUsername(config.get(ConfigConverters.ofString(), "db.username"));
hikaryConfig.setPassword(config.get(ConfigConverters.ofString(), "db.password"));
HikariDataSource dataSource = new HikariDataSource(hikaryConfig);
Configuration jooqConfiguration = new DefaultConfiguration();
jooqConfiguration.set(new DataSourceConnectionProvider(dataSource));
jooqConfiguration.set(DATABASE_DIALECT);
return jooqConfiguration;
}
示例11: testHsqlDb
import org.jooq.impl.DefaultConfiguration; //导入依赖的package包/类
@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());
}
示例12: testIgnoreFields
import org.jooq.impl.DefaultConfiguration; //导入依赖的package包/类
@Test
public void testIgnoreFields() throws Exception {
Connection conn = DbHelper.objectDb();
DSLContext dsl = DSL
.using(new DefaultConfiguration().set(conn)
.set(SQLDialect.HSQLDB)
.set(SfmRecordMapperProviderFactory.newInstance().addAlias("id", "noId").ignorePropertyNotFound().newProvider()));
List<DbObject> list = dsl.select()
.from("TEST_DB_OBJECT").fetchInto(DbObject.class);
assertEquals(2, list.size());
assertEquals(0, list.get(0).getId());
list.get(0).setId(1);
DbHelper.assertDbObjectMapping(list.get(0));
}
示例13: init
import org.jooq.impl.DefaultConfiguration; //导入依赖的package包/类
@Setup
public void init() throws Exception {
ConnectionParam cp = new ConnectionParam();
cp.db = db;
cp.init();
dslNoSfmMapping = DSL.using(new DefaultConfiguration().set(cp.dataSource).set(
db.getSqlDialect()));
dslNoSfmMappingselectFromSmallBenchMark = dslNoSfmMapping.selectFrom(TestSmallBenchmarkObject.TEST_SMALL_BENCHMARK_OBJECT);
dslSfmMapping = DSL.
using(new DefaultConfiguration().set(cp.dataSource)
.set(db.getSqlDialect())
.set(new SfmRecordMapperProvider()));
dslSfmMappingselectFromSmallBenchMark = dslSfmMapping.selectFrom(TestSmallBenchmarkObject.TEST_SMALL_BENCHMARK_OBJECT);
}
示例14: CollectModelManager
import org.jooq.impl.DefaultConfiguration; //导入依赖的package包/类
public CollectModelManager(SurveyManager surveyManager,
RecordManager recordManager,
CodeListManager codeListManager,
SpeciesManager speciesManager,
RecordFileManager recordFileManager,
Database database) {
this.surveyManager = surveyManager;
this.recordManager = recordManager;
this.codeListManager = codeListManager;
this.speciesManager = speciesManager;
this.recordFileManager = recordFileManager;
codeListSizeEvaluator = new CodeListSizeEvaluator(new DatabaseCodeListSizeDao(database));
DefaultConfiguration defaultConfiguration = new DefaultConfiguration();
defaultConfiguration.setSettings(defaultConfiguration.settings().withRenderSchema(false));
defaultConfiguration
.set(database.dataSource())
.set(SQLDialect.SQLITE);
jooqDsl = new CollectDSLContext(defaultConfiguration);
}
示例15: runHealthCheck
import org.jooq.impl.DefaultConfiguration; //导入依赖的package包/类
private HealthCheck.Result runHealthCheck(MockDataProvider provider) throws Exception {
MockConnection mockConnection = new MockConnection(provider) {
@Override
public Savepoint setSavepoint() throws SQLException {
return new Savepoint() {
@Override
public int getSavepointId() throws SQLException {
return 0;
}
@Override
public String getSavepointName() throws SQLException {
return "savepoint";
}
};
}
};
Configuration configuration = new DefaultConfiguration().set(mockConnection);
configuration.settings().setExecuteLogging(false);
JooqHealthCheck healthCheck = new JooqHealthCheck(configuration, validationQuery);
return healthCheck.check();
}