本文整理汇总了Java中com.zaxxer.hikari.HikariConfig.setInitializationFailFast方法的典型用法代码示例。如果您正苦于以下问题:Java HikariConfig.setInitializationFailFast方法的具体用法?Java HikariConfig.setInitializationFailFast怎么用?Java HikariConfig.setInitializationFailFast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.zaxxer.hikari.HikariConfig
的用法示例。
在下文中一共展示了HikariConfig.setInitializationFailFast方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dataSource
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Bean
public DataSource dataSource() {
logger.debug("Configuring Datasource");
String databaseUrl = String.format("jdbc:mysql://%s:%s/%s?%s",
databaseHostname, databasePort, databaseSchema, databaseOptions);
logger.info("database.url:" + databaseUrl);
logger.info("database.user:" + databaseUser);
HikariConfig config = new HikariConfig();
config.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
config.addDataSourceProperty("url", databaseUrl);
config.addDataSourceProperty("user", databaseUser);
config.setInitializationFailFast(false);
config.setIdleTimeout(60000);
String forcePassword = System.getenv("MYSQL_ROOT_PASSWORD");
// coming from environnment host
if (forcePassword != null) {
logger.info("Force the mysql password from host env");
databasePassword = forcePassword;
}
logger.info("URL : " + databaseUrl + " password : " + databasePassword);
config.addDataSourceProperty("password", databasePassword);
return new HikariDataSource(config);
}
示例2: setup
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
protected void setup(Jecon jecon, HikariConfig hikariConfig) {
this.jecon = jecon;
if (config == null) {
config = jecon.getConfigStruct();
}
this.prefix = config.getDbConfig().prefix;
hikariConfig.setJdbcUrl(config.getDbConfig().url);
hikariConfig.setInitializationFailFast(true);
hikariConfig.setAutoCommit(true);
hikariConfig.setConnectionInitSql("/* Jecon */SELECT 1");
if (config.getDbConfig().poolSize > 0) {
hikariConfig.setMaximumPoolSize(config.getDbConfig().poolSize);
}
if (config.getDbConfig().timeout > 0) {
hikariConfig.setIdleTimeout(config.getDbConfig().timeout);
}
hikariConfig.setDataSourceProperties(config.getDbConfig().propaties);
// HikariDataSourceをインスタンス化
this.hikariDc = new HikariDataSource(hikariConfig);
this.createTable();
}
示例3: 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);
}
示例4: initialize
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
/**
* Called in onEnable, initializes the pool and configures it and opens the first connection to spawn the pool.
*/
public static void initialize(Plugin plugin, GlobalConfig globalConfig) {
try {
DB.plugin = plugin;
timingManager = TimingManager.of(plugin);
HikariConfig config = new HikariConfig();
config.setPoolName("VGL-Client");
config.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
config.addDataSourceProperty("url", globalConfig.persistence.url);
config.addDataSourceProperty("user", globalConfig.persistence.user);
config.addDataSourceProperty("password", globalConfig.persistence.pass);
config.addDataSourceProperty("cachePrepStmts", true);
config.addDataSourceProperty("prepStmtCacheSize", 250);
config.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
config.addDataSourceProperty("useServerPrepStmts", true);
config.addDataSourceProperty("cacheCallableStmts", true);
config.addDataSourceProperty("cacheResultSetMetadata", true);
config.addDataSourceProperty("cacheServerConfiguration", true);
config.addDataSourceProperty("useLocalSessionState", true);
config.addDataSourceProperty("elideSetAutoCommits", true);
config.addDataSourceProperty("alwaysSendSetIsolation", false);
config.setConnectionTestQuery("SELECT 1");
config.setInitializationFailFast(true);
config.setMinimumIdle(3);
config.setMaximumPoolSize(5);
pooledDataSource = new HikariDataSource(config);
pooledDataSource.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new AsyncDbQueue(), 0, 1);
log.info("Started database pool to " + globalConfig.persistence.url);
} catch (Exception ex) {
pooledDataSource = null;
log.severe("Error creating database pool");
ex.printStackTrace();
}
}
示例5: getCommonConfig
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private HikariConfig getCommonConfig() {
final HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setPoolName("defaultDatabase");
hikariConfig.setDriverClassName(driverClassName);
hikariConfig.setMaximumPoolSize(maximumPoolSize);
hikariConfig.setConnectionTimeout(TimeUnit.SECONDS.toMillis(5));
if (runtimeEnvironmentUtil.isProductionEnvironment()) {
hikariConfig.setInitializationFailFast(false);
}
return hikariConfig;
}
示例6: init
import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Override
public void init() {
HikariConfig config = new HikariConfig();
config.setPoolName("luckperms");
appendConfigurationInfo(config);
appendProperties(config, this.configuration);
config.setMaximumPoolSize(this.configuration.getMaxPoolSize());
config.setMinimumIdle(this.configuration.getMinIdleConnections());
config.setMaxLifetime(this.configuration.getMaxLifetime());
config.setConnectionTimeout(this.configuration.getConnectionTimeout());
// If a connection is not returned within 10 seconds, it's probably safe to assume it's been leaked.
config.setLeakDetectionThreshold(TimeUnit.SECONDS.toMillis(10)); // 10000
// The drivers are really old in some of the older Spigot binaries, so Connection#isValid doesn't work.
config.setConnectionTestQuery("/* LuckPerms ping */ SELECT 1");
try {
// don't perform any initial connection validation - we subsequently call #getConnection
// to setup the schema anyways
config.setInitializationFailTimeout(-1);
} catch (NoSuchMethodError e) {
//noinspection deprecation
config.setInitializationFailFast(false);
}
this.hikari = new HikariDataSource(config);
}