本文整理汇总了Java中com.zaxxer.hikari.HikariDataSource.setConnectionTimeout方法的典型用法代码示例。如果您正苦于以下问题:Java HikariDataSource.setConnectionTimeout方法的具体用法?Java HikariDataSource.setConnectionTimeout怎么用?Java HikariDataSource.setConnectionTimeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.zaxxer.hikari.HikariDataSource
的用法示例。
在下文中一共展示了HikariDataSource.setConnectionTimeout方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialiseDBConnectionPool
import com.zaxxer.hikari.HikariDataSource; //导入方法依赖的package包/类
private synchronized void initialiseDBConnectionPool() throws ConfigurationException {
try {
if (this.dataSource == null) {
HikariDataSource hikariDataSource = new HikariDataSource();
hikariDataSource.setJdbcUrl(postgresUrl);
hikariDataSource.setUsername(postgresUsername);
hikariDataSource.setPassword(postgresPassword);
hikariDataSource.setDriverClassName("org.postgresql.Driver");
hikariDataSource.setMaximumPoolSize(15);
hikariDataSource.setMinimumIdle(2);
hikariDataSource.setIdleTimeout(60000);
hikariDataSource.setConnectionTimeout(5000L);
hikariDataSource.setPoolName("HL7ReceiverDBConnectionPool");
this.dataSource = hikariDataSource;
}
} catch (Exception e) {
throw new ConfigurationException("Error creating Hikari connection pool", e);
}
}
示例2: createHikariDataSource
import com.zaxxer.hikari.HikariDataSource; //导入方法依赖的package包/类
private HikariDataSource createHikariDataSource(JdbcProperties jdbcProperties) {
HikariDataSource hikariDataSource = new HikariDataSource();
hikariDataSource.setJdbcUrl(jdbcProperties.getJdbcUrl());
hikariDataSource.setUsername(jdbcProperties.getUsername());
hikariDataSource.setPassword(jdbcProperties.getPassword());
JdbcPoolProperties jdbcPoolProperties = jdbcProperties.getJdbcPool();
hikariDataSource.setAutoCommit(jdbcPoolProperties.isAutoCommit());
hikariDataSource.setConnectionTimeout(jdbcPoolProperties.getConnectionTimeout());
hikariDataSource.setIdleTimeout(jdbcPoolProperties.getIdleTimeout());
hikariDataSource.setMaxLifetime(jdbcPoolProperties.getMaxLifetime());
hikariDataSource.setMaximumPoolSize(jdbcPoolProperties.getMaximumPoolSize());
hikariDataSource.setMinimumIdle(jdbcPoolProperties.getMinimumIdle());
hikariDataSource
.setInitializationFailTimeout(jdbcPoolProperties.getInitializationFailTimeout());
hikariDataSource.setIsolateInternalQueries(jdbcPoolProperties.isIsolateInternalQueries());
hikariDataSource.setReadOnly(jdbcPoolProperties.isReadOnly());
hikariDataSource.setRegisterMbeans(jdbcPoolProperties.isRegisterMbeans());
Optional.ofNullable(jdbcPoolProperties.getDriverClassName())
.ifPresent(hikariDataSource::setDriverClassName);
hikariDataSource.setValidationTimeout(jdbcPoolProperties.getValidationTimeout());
hikariDataSource.setLeakDetectionThreshold(jdbcPoolProperties.getLeakDetectionThreshold());
return hikariDataSource;
}
示例3: buildH2Datasource
import com.zaxxer.hikari.HikariDataSource; //导入方法依赖的package包/类
private static HikariDataSource buildH2Datasource() {
HikariDataSource ds = new HikariDataSource();
ds.addDataSourceProperty("cachePrepStmts", true);
ds.addDataSourceProperty("prepStmtCacheSize", 250);
ds.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
ds.addDataSourceProperty("useServerPrepStmts", true);
ds.setMaximumPoolSize(3);
ds.setConnectionTimeout(5000);
ds.setJdbcUrl("jdbc:h2:mem:DBName;MODE=MYSQL;DB_CLOSE_DELAY=-1;TRACE_LEVEL_SYSTEM_OUT=0");
ds.setDriverClassName("org.h2.Driver");
ds.setUsername("sa");
ds.setPassword("");
return ds;
}
示例4: create
import com.zaxxer.hikari.HikariDataSource; //导入方法依赖的package包/类
public HikariDataSource create() {
HikariDataSource ds = new HikariDataSource();
ds.addDataSourceProperty("cachePrepStmts", true);
ds.addDataSourceProperty("prepStmtCacheSize", 250);
ds.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
ds.addDataSourceProperty("useServerPrepStmts", true);
ds.setMaximumPoolSize(3);
ds.setConnectionTimeout(5000);
this.setPreDestory("close");// jBeanBox will close pool
return ds;
}
示例5: create
import com.zaxxer.hikari.HikariDataSource; //导入方法依赖的package包/类
public HikariDataSource create() {
HikariDataSource ds = new HikariDataSource();
ds.addDataSourceProperty("cachePrepStmts", true);
ds.addDataSourceProperty("prepStmtCacheSize", 250);
ds.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
ds.addDataSourceProperty("useServerPrepStmts", true);
ds.setMaximumPoolSize(10);
ds.setConnectionTimeout(5000);
this.setPreDestory("close");// jBeanBox will close pool
return ds;
}
示例6: register
import com.zaxxer.hikari.HikariDataSource; //导入方法依赖的package包/类
@Override
public boolean register() {
if (IsRegistered) {
return HAS_REGISTERED;
}
HikariDataSource ds = new HikariDataSource();
//basic config
ds.setJdbcUrl(jdbcURL);
ds.setDriverClassName(jdbcDriver);
ds.setUsername(jdbcUsername);
ds.setPassword(jdbcPassword);
//custom config
ds.setAutoCommit(autoCommit);
ds.setConnectionTimeout(connectionTimeout);
ds.setIdleTimeout(idleTimeout);
ds.setMaxLifetime(maxLifetime);
ds.setMaximumPoolSize(maximumPoolSize);
ds.setValidationTimeout(validationTimeout);
ds.setLeakDetectionThreshold(leakDetectionThreshold);
if (!StrUtil.isBlank(poolName)) {
ds.setPoolName(poolName);
}
if (!StrUtil.isBlank(catalog)) {
ds.setCatalog(catalog);
}
if (!StrUtil.isBlank(connectionInitSql)) {
ds.setConnectionInitSql(connectionInitSql);
}
if (!StrUtil.isBlank(transactionIsolation)) {
ds.setTransactionIsolation(transactionIsolation);
}
if (jdbcURL.contains(":mysql:")) {
ds.addDataSourceProperty("cachePrepStmts", "true");
ds.addDataSourceProperty("prepStmtCacheSize", "250");
ds.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
ds.addDataSourceProperty("useServerPrepStmts", "true");
}
setDataSource(ds);
setIsRegistered(HAS_REGISTERED);
return HAS_REGISTERED;
}