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


Java HikariConfig.setMinimumIdle方法代码示例

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


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

示例1: setupPool

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private void setupPool() {
    HikariConfig config = new HikariConfig();

    config.setJdbcUrl("jdbc:mysql://" + this.credentials.getHostname() + ":" + this.credentials.getPort() + "/" + this.credentials.getDatabaseName());
    config.setDriverClassName("com.mysql.jdbc.Driver");
    config.setUsername(this.credentials.getUsername());
    config.setPassword(this.credentials.getPassword());
    config.setMinimumIdle(this.minimumConnections);
    config.setMaximumPoolSize(this.maximumConnections);
    config.setConnectionTimeout(this.connectionTimeout);

    try {
        this.dataSource = new HikariDataSource(config);
    }
    catch (Exception e) {
        Bukkit.getLogger().severe("[ZorahPractice] - Unable to establish MySQL connection, plugin disabled.");
        Bukkit.getServer().getPluginManager().disablePlugin(PracticePlugin.getInstance());
    }
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:20,代码来源:ConnectionPoolManager.java

示例2: dataSource

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Bean(destroyMethod = "close")
public DataSource dataSource() {
    HikariConfig dataSourceConfig = new HikariConfig();
    dataSourceConfig.setDriverClassName(environment.getRequiredProperty("spring.datasource.driver-class-name"));
    dataSourceConfig.setJdbcUrl(environment.getRequiredProperty("spring.datasource.url"));
    dataSourceConfig.setUsername(environment.getRequiredProperty("spring.datasource.username"));
    dataSourceConfig.setPassword(environment.getRequiredProperty("spring.datasource.password"));
    dataSourceConfig.setMaximumPoolSize(Integer.parseInt(environment.getRequiredProperty("spring.datasource.maximumPoolSize")));
    dataSourceConfig.setMinimumIdle(Integer.parseInt(environment.getRequiredProperty("spring.datasource.minimumIdle")));
    dataSourceConfig.setMaxLifetime(Integer.parseInt(environment.getRequiredProperty("spring.datasource.maxLifetime")));
    dataSourceConfig.setConnectionTimeout(Long.parseLong(environment.getRequiredProperty("spring.datasource.connectionTimeout")));
    dataSourceConfig.setIdleTimeout(Long.parseLong(environment.getRequiredProperty("spring.datasource.idleTimeout")));
    dataSourceConfig.addDataSourceProperty("poolName", environment.getRequiredProperty("spring.datasource.poolName"));
    dataSourceConfig.addDataSourceProperty("cachePrepStmts", "true");
    dataSourceConfig.addDataSourceProperty("prepStmtCacheSize", "250");
    dataSourceConfig.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
    return new HikariDataSource(dataSourceConfig);
}
 
开发者ID:RizkiMufrizal,项目名称:Spring-OAuth2-Custom,代码行数:19,代码来源:DataSourceConfiguration.java

示例3: getDataSourceFromConfig

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
public static HikariDataSource getDataSourceFromConfig(
    Config conf
    , MetricRegistry metricRegistry
    , HealthCheckRegistry healthCheckRegistry) {

    HikariConfig jdbcConfig = new HikariConfig();
    jdbcConfig.setPoolName(conf.getString("poolName"));
    jdbcConfig.setMaximumPoolSize(conf.getInt("maximumPoolSize"));
    jdbcConfig.setMinimumIdle(conf.getInt("minimumIdle"));
    jdbcConfig.setJdbcUrl(conf.getString("jdbcUrl"));
    jdbcConfig.setUsername(conf.getString("username"));
    jdbcConfig.setPassword(conf.getString("password"));

    jdbcConfig.addDataSourceProperty("cachePrepStmts", conf.getBoolean("cachePrepStmts"));
    jdbcConfig.addDataSourceProperty("prepStmtCacheSize", conf.getInt("prepStmtCacheSize"));
    jdbcConfig.addDataSourceProperty("prepStmtCacheSqlLimit", conf.getInt("prepStmtCacheSqlLimit"));
    jdbcConfig.addDataSourceProperty("useServerPrepStmts", conf.getBoolean("useServerPrepStmts"));

    // Add HealthCheck
    jdbcConfig.setHealthCheckRegistry(healthCheckRegistry);

    // Add Metrics
    jdbcConfig.setMetricRegistry(metricRegistry);
    return new HikariDataSource(jdbcConfig);
}
 
开发者ID:StubbornJava,项目名称:StubbornJava,代码行数:26,代码来源:ConnectionPool.java

示例4: initConnection

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private void initConnection() throws Exception {
	HikariConfig config = new HikariConfig();
	config.setPoolName("Parties");
	config.setJdbcUrl(Variables.storage_settings_mysql_url);
	config.setUsername(Variables.storage_settings_mysql_username);
	config.setPassword(Variables.storage_settings_mysql_password);
	config.setMaximumPoolSize(Variables.storage_settings_mysql_poolsize);
	config.setMinimumIdle(Variables.storage_settings_mysql_poolsize);
	config.setMaxLifetime(Variables.storage_settings_mysql_connlifetime);
	config.setIdleTimeout(Variables.storage_settings_mysql_conntimeout);
	
	// Properties: https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html
	config.addDataSourceProperty("cachePreStmts", "true"); // Enable Prepared Statement caching
	config.addDataSourceProperty("prepStmtCacheSize", "25"); // How many PS cache, default: 25
	config.addDataSourceProperty("useServerPrepStmts", "true"); // If supported use PS server-side
	config.addDataSourceProperty("useLocalSessionState", "true"); // Enable setAutoCommit
	config.addDataSourceProperty("useLocalTransactionState", "true"); // Enable commit/rollbacks
	
	hikariDataSource = new HikariDataSource(config);
}
 
开发者ID:AlessioDP,项目名称:Parties,代码行数:21,代码来源:MySQLData.java

示例5: HikariCpImpl

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
public HikariCpImpl() {
    Properties properties = new Properties();
    properties.setProperty("dataSourceClassName", "com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
    properties.setProperty("dataSource.serverName", "127.0.0.1");
    properties.setProperty("dataSource.portNumber", "3306");
    properties.setProperty("dataSource.databaseName", "study");
    properties.setProperty("dataSource.user", "root");
    properties.setProperty("dataSource.password", "zhilaiadmin");
    properties.setProperty("dataSource.encoding", "UTF-8");
    properties.setProperty("maximumPoolSize", "100");
    HikariConfig config = new HikariConfig(properties);
    config.setConnectionTimeout(30 * 1000);
    config.setIdleTimeout(60 * 1000);
    config.setMaxLifetime(60 * 1000);
    config.setMinimumIdle(50);
    config.addDataSourceProperty("cachePrepStmts", "true");
    config.addDataSourceProperty("prepStmtCacheSize", "1000");
    config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
    ds = new HikariDataSource(config);
}
 
开发者ID:amao12580,项目名称:JOOQ,代码行数:21,代码来源:HikariCpImpl.java

示例6: start

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Override
public void start() {
	HikariConfig config = new HikariConfig();
	config.setJdbcUrl(this.conURL);
	config.setUsername(this.username);
	config.setPassword(this.password);
	config.setDriverClassName(this.driverName);
	config.setMaximumPoolSize(max);
	config.setMinimumIdle(min);
	if (this.testSql != null && this.testSql.trim().length() > 0) {
		config.setConnectionTestQuery(testSql);
	}
	config.setPoolName("HikariCPPool[" + username + "]");
	config.addDataSourceProperty("cachePrepStmts", AppProperties.get("HikariCPPool_cachePrepStmts", "true"));
	config.addDataSourceProperty("prepStmtCacheSize", AppProperties.get("HikariCPPool_prepStmtCacheSize", "250"));
	config.addDataSourceProperty("prepStmtCacheSqlLimit",
			AppProperties.get("HikariCPPool_prepStmtCacheSqlLimit", "2048"));
	config.setConnectionTimeout(AppProperties.getAsInt("HikariCPPool_connectionTimeout", 30000));
	config.setIdleTimeout(AppProperties.getAsInt("HikariCPPool_idleTimeout", 600000));
	config.setMaxLifetime(AppProperties.getAsInt("HikariCPPool_maxLifetime", 1800000));
	// HikariDataSource ds = new HikariDataSource(config);
	// this.datasource=ds.getDataSource();
	this.datasource = new HikariDataSource(config);
}
 
开发者ID:jbeetle,项目名称:BJAF3.x,代码行数:25,代码来源:HikariCPPool.java

示例7: getDataSource

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private HikariDataSource getDataSource(String jdbcUrl, int poolSize) {
    HikariConfig hikariConfig = new HikariConfig();
    hikariConfig.setJdbcUrl(jdbcUrl);
    hikariConfig.setConnectionTestQuery("SELECT 1");
    hikariConfig.setMinimumIdle(1);
    hikariConfig.setMaximumPoolSize(poolSize);

    return new HikariDataSource(hikariConfig);
}
 
开发者ID:testcontainers,项目名称:testcontainers-java-module-mariadb,代码行数:10,代码来源:JDBCDriverTest.java

示例8: doBenchHikari

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private void doBenchHikari() throws Exception {
    HikariConfig config = new HikariConfig();
    config.setDataSource(new StubDataSource());
    config.setUsername("brettw");
    config.setPassword("");
    config.setMinimumIdle(0);
    config.setMaximumPoolSize(32);
    config.setConnectionTimeout(8000);
    config.setAutoCommit(false);
    DataSource ds = new HikariDataSource(config);
    doBench(ds);
    ((AutoCloseable) ds).close();
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:14,代码来源:Bench.java

示例9: hikariConfig

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private HikariConfig hikariConfig() {
    HikariConfig config = new HikariConfig();
    config.setDriverClassName(driverClassName);
    config.setJdbcUrl(url);
    config.setUsername(username);
    config.setPassword(password);
    config.setPoolName(poolName);
    config.setMaximumPoolSize(20);
    config.setMinimumIdle(2);
    config.setIdleTimeout(TimeUnit.SECONDS.toMillis(30));
    config.addDataSourceProperty("cachePrepStmts", "true");
    config.addDataSourceProperty("prepStmtCacheSize", "250");
    config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
    return config;
}
 
开发者ID:JUGIstanbul,项目名称:second-opinion-api,代码行数:16,代码来源:DataSourceConfiguration.java

示例10: get

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Override
public DataSource get() throws SQLException {
    HikariConfig config = new HikariConfig();
    config.setJdbcUrl(baseConfig.getJdbcUrl());
    config.setUsername(baseConfig.getUsername());
    config.setPassword(baseConfig.getPassword());
    config.setMinimumIdle(baseConfig.getMinimumIdle());
    config.setMaximumPoolSize(baseConfig.getMaximumPoolSize());
    config.setConnectionTestQuery(baseConfig.getConnectionTestQuery());
    config.setIdleTimeout(baseConfig.getIdleTimeout());
    config.setConnectionTimeout(baseConfig.getConnectionTimeout());

    return new HikariDataSource(config);
}
 
开发者ID:Twister915,项目名称:pl,代码行数:15,代码来源:ConfiguredDataSourceProvider.java

示例11: 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

示例12: getDataSource

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Bean
@Primary
public DataSource getDataSource() {
    HikariConfig config = new HikariConfig();
    config.setDriverClassName("com.mysql.jdbc.Driver");
    config.setJdbcUrl("jdbc:mysql://localhost:3306/test");
    config.setUsername("root");
    config.setPassword("root");
    config.setMaximumPoolSize(500);
    config.setMinimumIdle(10);
    return new HikariDataSource(config);
}
 
开发者ID:SkywalkingTest,项目名称:Agent-Benchmarks,代码行数:13,代码来源:DataSourceConfiguration.java

示例13: getDataSource

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Bean
public static DataSource getDataSource() {
    HikariConfig config = new HikariConfig();
    config.setJdbcUrl(getRequiredProperty(VEILARBJOBBSOKERKOMPETANSEDB_URL));
    config.setUsername(getRequiredProperty(VEILARBJOBBSOKERKOMPETANSEDB_USERNAME));
    config.setPassword(getRequiredProperty(VEILARBJOBBSOKERKOMPETANSEDB_PASSWORD));
    config.setMaximumPoolSize(10);
    config.setMinimumIdle(2);

    return new HikariDataSource(config);
}
 
开发者ID:navikt,项目名称:fo-veilarbjobbsokerkompetanse,代码行数:12,代码来源:DataSourceConfig.java

示例14: setupPool

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
private void setupPool() {
    HikariConfig config = new HikariConfig();
    config.setJdbcUrl("jdbc:mysql://" + hostname + ":" + port + "/" + database);
    config.setDriverClassName("com.mysql.jdbc.Driver");
    config.setUsername(username);
    config.setPassword(password);
    config.setMinimumIdle(minimumIdle);
    config.setMaximumPoolSize(poolSize);
    config.setConnectionTimeout(connectionTimeout);
    config.setConnectionTestQuery(testQuery);
    config.addDataSourceProperty("cachePrepStmts", "true");
    config.addDataSourceProperty("prepStmtCacheSize", "250");
    config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
    dataSource = new HikariDataSource(config);
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:16,代码来源:ConnectionPoolManager.java

示例15: HikariCPComponent

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
public HikariCPComponent(OptionMap options) {
    config = new HikariConfig();
    if (options.containsKey("uri")) config.setJdbcUrl(options.getString("uri"));
    if (options.containsKey("username")) config.setUsername(options.getString("username"));
    if (options.containsKey("password")) config.setPassword(options.getString("password"));
    if (options.containsKey("autoCommit?")) config.setAutoCommit(options.getBoolean("autoCommit?"));
    if (options.containsKey("connTimeout")) config.setConnectionTimeout(options.getLong("connTimeout"));
    if (options.containsKey("idleTimeout")) config.setIdleTimeout(options.getLong("idleTimeout"));
    if (options.containsKey("maxLifetime")) config.setMaxLifetime(options.getLong("maxLifetime"));
    if (options.containsKey("maxPoolSize")) config.setMaximumPoolSize(options.getInt("maxPoolSize"));
    if (options.containsKey("minIdle")) config.setMinimumIdle(options.getInt("minIdle"));
    if (options.containsKey("poolName")) config.setPoolName(options.getString("uri"));
}
 
开发者ID:kawasima,项目名称:enkan,代码行数:14,代码来源:HikariCPComponent.java


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