本文整理汇总了Java中com.zaxxer.hikari.HikariConfig.setTransactionIsolation方法的典型用法代码示例。如果您正苦于以下问题:Java HikariConfig.setTransactionIsolation方法的具体用法?Java HikariConfig.setTransactionIsolation怎么用?Java HikariConfig.setTransactionIsolation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.zaxxer.hikari.HikariConfig
的用法示例。
在下文中一共展示了HikariConfig.setTransactionIsolation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: provide
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Override
public DataSource provide() {
LOGGER.debug("{}", this);
HikariConfig config = new HikariConfig();
config.setJdbcUrl(jdbcUrl);
config.setUsername(username);
config.setPassword(password);
config.setAutoCommit(autoCommit);
config.setMaximumPoolSize(maximumPoolSize);
config.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
HikariDataSource dataSource = new HikariDataSource(config);
LOGGER.debug("provide DataSource {}", dataSource);
return dataSource;
}
示例2: apply
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Override
public DataSourceHolder apply(SourceKey key)
{
final HikariConfig newConfig = new HikariConfig(baseConfig);
newConfig.setDriverClassName(driverClass);
newConfig.setUsername(key.getUsername());
newConfig.setPassword(key.getPassword());
newConfig.setJdbcUrl(key.getUrl());
//Fixed properties: (i.e. do not allow override in hikari.properties)
newConfig.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
newConfig.setAutoCommit(false);
newConfig.setInitializationFailFast(false);
newConfig.setThreadFactory(new ThreadFactory()
{
@Override
public Thread newThread(final Runnable r)
{
return new Thread("CustomHikariThread")
{
@Override
public void run()
{
ClassLoader oldLoader = getContextClassLoader();
try
{
setContextClassLoader(DataSourceServiceImpl.class.getClassLoader());
r.run();
}
catch( Throwable t )
{
setContextClassLoader(oldLoader);
}
}
};
}
});
return new DataSourceHolder(new HikariDataSource(newConfig), dialect);
}
示例3: getHikariConfig
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private HikariConfig getHikariConfig(AgroalDataSourceConfiguration dataSourceConfiguration) {
if ( dataSourceConfiguration.isXA() ) {
throw new UnsupportedOperationException( "Unsupported. Hikari does not support XA" );
}
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setDataSourceJNDI( dataSourceConfiguration.jndiName() );
hikariConfig.setLeakDetectionThreshold( poolConfiguration.leakTimeout().toMillis() );
hikariConfig.setIdleTimeout( poolConfiguration.reapTimeout().toMillis() );
hikariConfig.setValidationTimeout( poolConfiguration.validationTimeout().toMillis() );
if ( factoryConfiguration.jdbcTransactionIsolation().isDefined() ) {
hikariConfig.setTransactionIsolation( "TRANSACTION_" + factoryConfiguration.jdbcTransactionIsolation().name() );
}
hikariConfig.setJdbcUrl( factoryConfiguration.jdbcUrl() );
hikariConfig.setAutoCommit( factoryConfiguration.autoCommit() );
hikariConfig.setConnectionInitSql( factoryConfiguration.initialSql() );
Principal principal = factoryConfiguration.principal();
if ( principal != null ) {
hikariConfig.setUsername( factoryConfiguration.principal().getName() );
}
for ( Object credential : factoryConfiguration.credentials() ) {
if ( credential instanceof SimplePassword ) {
hikariConfig.setPassword( ( (SimplePassword) credential ).getWord() );
}
}
hikariConfig.setMaximumPoolSize( poolConfiguration.maxSize() );
hikariConfig.setConnectionTimeout( poolConfiguration.acquisitionTimeout().toMillis() );
hikariConfig.setDriverClassName( factoryConfiguration.driverClassName() );
return hikariConfig;
}
示例4: build
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Override
public ManagedDataSource build(final MetricRegistry metricRegistry, final String name) {
final Properties properties = new Properties();
for (final Map.Entry<String, String> property : this.properties.entrySet()) {
properties.setProperty(property.getKey(), property.getValue());
}
final HikariConfig config = new HikariConfig();
config.setDataSourceProperties(properties);
if (this.autoCommitByDefault.isPresent()) {
config.setAutoCommit(this.autoCommitByDefault.get());
}
config.setCatalog(this.defaultCatalog);
if (this.readOnlyByDefault.isPresent()) {
config.setReadOnly(this.readOnlyByDefault.get());
}
config.setDriverClassName(this.driverClass);
config.setConnectionInitSql(this.initializationQuery);
config.setMaximumPoolSize(this.maxSize);
config.setMinimumIdle(this.minSize);
if (this.getMaxConnectionAge().isPresent()) {
config.setMaxLifetime(this.maxConnectionAge.toMilliseconds());
}
config.setPoolName(name);
config.setJdbcUrl(this.url);
config.setUsername(this.user);
config.setPassword(this.user != null && this.password == null ? "" : this.password);
config.setConnectionTestQuery(this.validationQuery);
if (this.getValidationQueryTimeout().isPresent()) {
config.setValidationTimeout(this.validationQueryTimeout.toMilliseconds());
}
if (this.defaultTransactionIsolation.isPresent()) {
config.setTransactionIsolation(this.defaultTransactionIsolation.get().toString());
}
return new ManagedPooledDataSource(config, metricRegistry);
}