当前位置: 首页>>代码示例>>Java>>正文


Java HikariConfig.setValidationTimeout方法代码示例

本文整理汇总了Java中com.zaxxer.hikari.HikariConfig.setValidationTimeout方法的典型用法代码示例。如果您正苦于以下问题:Java HikariConfig.setValidationTimeout方法的具体用法?Java HikariConfig.setValidationTimeout怎么用?Java HikariConfig.setValidationTimeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.zaxxer.hikari.HikariConfig的用法示例。


在下文中一共展示了HikariConfig.setValidationTimeout方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDefaultHikariConfig

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Nonnull
public static HikariConfig getDefaultHikariConfig() {
    final HikariConfig hikariConfig = new HikariConfig();

    //more database connections don't help with performance, so use a default value based on available cores
    //http://www.dailymotion.com/video/x2s8uec_oltp-performance-concurrent-mid-tier-connections_tech
    hikariConfig.setMaximumPoolSize(Math.max(Runtime.getRuntime().availableProcessors(), 4));

    //timeout the validation query (will be done automatically through Connection.isValid())
    hikariConfig.setValidationTimeout(3000);
    hikariConfig.setConnectionTimeout(10000);
    hikariConfig.setAutoCommit(false);

    hikariConfig.setDriverClassName("org.postgresql.Driver");

    return hikariConfig;
}
 
开发者ID:napstr,项目名称:SqlSauce,代码行数:18,代码来源:DatabaseConnection.java

示例2: 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;
}
 
开发者ID:agroal,项目名称:agroal,代码行数:37,代码来源:HikariUnderTheCovers.java

示例3: 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);
}
 
开发者ID:mtakaki,项目名称:dropwizard-hikaricp,代码行数:37,代码来源:DataSourceFactory.java


注:本文中的com.zaxxer.hikari.HikariConfig.setValidationTimeout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。