本文整理汇总了Java中org.jooq.conf.Settings类的典型用法代码示例。如果您正苦于以下问题:Java Settings类的具体用法?Java Settings怎么用?Java Settings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Settings类属于org.jooq.conf包,在下文中一共展示了Settings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupDatabase
import org.jooq.conf.Settings; //导入依赖的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: setUp
import org.jooq.conf.Settings; //导入依赖的package包/类
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();
}
}
示例3: dbContext
import org.jooq.conf.Settings; //导入依赖的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;
}
示例4: dslContext
import org.jooq.conf.Settings; //导入依赖的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);
}
示例5: DslContextConfiguration
import org.jooq.conf.Settings; //导入依赖的package包/类
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();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:JooqAutoConfiguration.java
示例6: dsl
import org.jooq.conf.Settings; //导入依赖的package包/类
@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);
}
示例7: doInJOOQ
import org.jooq.conf.Settings; //导入依赖的package包/类
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();
}
}
}
开发者ID:vladmihalcea,项目名称:high-performance-java-persistence,代码行数:24,代码来源:AbstractJOOQIntegrationTest.java
示例8: mockConnector
import org.jooq.conf.Settings; //导入依赖的package包/类
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();
}
};
}
示例9: SqlReportDataExtractor
import org.jooq.conf.Settings; //导入依赖的package包/类
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();
}
示例10: test05
import org.jooq.conf.Settings; //导入依赖的package包/类
@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);
}
}
示例11: test13
import org.jooq.conf.Settings; //导入依赖的package包/类
@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);
}
}
示例12: test18
import org.jooq.conf.Settings; //导入依赖的package包/类
@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);
}
}
示例13: test22
import org.jooq.conf.Settings; //导入依赖的package包/类
@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);
}
}
示例14: test23
import org.jooq.conf.Settings; //导入依赖的package包/类
@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);
}
}
示例15: createFactory
import org.jooq.conf.Settings; //导入依赖的package包/类
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);
}