當前位置: 首頁>>代碼示例>>Java>>正文


Java HikariConfig.setInitializationFailFast方法代碼示例

本文整理匯總了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);
}
 
開發者ID:oncecloud,項目名稱:devops-cstack,代碼行數:24,代碼來源:DatabaseConfiguration.java

示例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();
}
 
開發者ID:HimaJyun,項目名稱:Jecon,代碼行數:27,代碼來源:Database.java

示例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);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:40,代碼來源:DataSourceServiceImpl.java

示例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();
    }
}
 
開發者ID:VoxelGamesLib,項目名稱:VoxelGamesLibv2,代碼行數:43,代碼來源:DB.java

示例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;
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-web,代碼行數:15,代碼來源:DataSourceProperties.java

示例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);
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:32,代碼來源:HikariConnectionFactory.java


注:本文中的com.zaxxer.hikari.HikariConfig.setInitializationFailFast方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。