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


Java HikariConfig.setDataSourceProperties方法代码示例

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


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

示例1: hikariConfig

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Bean
public HikariConfig hikariConfig() {
    log.info("Creating HikariConfig with:\n* username: {}\n* jdbcUrl: {}", databaseProperties.getUsername(), databaseProperties.getUrl());

    HikariConfig config = new HikariConfig();
    config.setDriverClassName(databaseProperties.getDriverClassName());
    config.setJdbcUrl(databaseProperties.getUrl());
    config.setUsername(databaseProperties.getUsername());
    config.setPassword(databaseProperties.getPassword());
    config.setMaximumPoolSize(databaseProperties.getMaximumPoolSize());
    config.setIdleTimeout(databaseProperties.getIdleTimeout());
    config.setConnectionTestQuery(databaseProperties.getConnectionTestQuery());
    config.setPoolName(databaseProperties.getPoolName());
    config.setMetricsTrackerFactory(prometheusMetricsTrackerFactory());

    config.setDataSourceProperties(dataSourceProperties());

    return config;
}
 
开发者ID:amvnetworks,项目名称:amv-access-api-poc,代码行数:20,代码来源:DatabaseConfig.java

示例2: dataSource

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
@Bean
@ConditionalOnMissingBean
public DataSource dataSource() {
    HikariConfig configuration = new HikariConfig();
    configuration.setJdbcUrl(url);
    configuration.setUsername(username);
    configuration.setPassword(password);
    configuration.setAutoCommit(false);
    configuration.setMaximumPoolSize(maxPoolSize);
    configuration.setConnectionTimeout(connectionTimeout);
    configuration.setMaxLifetime(maxLifetime);
    Properties properties = new Properties();
    properties.setProperty("cachePrepStmts", cachePrepStmts);
    properties.setProperty("prepStmtCacheSize", prepStmtCacheSize);
    properties.setProperty("prepStmtCacheSqlLimit", prepStmtCacheSqlLimit);
    properties.setProperty("useServerPrepStmts", useServerPrepStmts);
    configuration.setDataSourceProperties(properties);
    configuration.setConnectionInitSql("SET NAMES " + connectionCharacter);
    return new HikariDataSource(configuration);
}
 
开发者ID:superkoh,项目名称:k-framework,代码行数:21,代码来源:MybatisAutoConfiguration.java

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

示例4: createHikari

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
public static HikariDataSource createHikari(String url, String user, String pass, Properties dsProps)
{
    HikariConfig config = new HikariConfig();

    config.setJdbcUrl(url);
    config.setUsername(user);
    config.setPassword(pass);

    config.setDataSourceProperties(dsProps);

    LOGGER.info("creating hikaricp datasource. using jdbc url {}", config.getJdbcUrl());

    return new HikariDataSource(config);
}
 
开发者ID:novarto-oss,项目名称:sane-dbc,代码行数:15,代码来源:Hikari.java

示例5: 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.setMetricRegistry(metricRegistry);
    if (healthCheckRegistry != null) {
        config.setHealthCheckRegistry(healthCheckRegistry);
    }

    config.setAutoCommit(autoCommit);
    config.setDataSourceProperties(properties);
    if (datasourceClassName != null) {
        config.setDataSourceClassName(datasourceClassName);
    } else {
        config.setDriverClassName(driverClass);
    }

    config.setMaximumPoolSize(maxSize);
    minSize.ifPresent(config::setMinimumIdle);
    config.setPoolName(name);
    config.setUsername(user);
    config.setPassword(user != null && password == null ? "" : password);
    return new HikariManagedPooledDataSource(config);
}
 
开发者ID:nickbabcock,项目名称:dropwizard-hikaricp-benchmark,代码行数:29,代码来源:HikariDataSourceFactory.java

示例6: dataSource

import com.zaxxer.hikari.HikariConfig; //导入方法依赖的package包/类
public DataSource dataSource() {
    HikariConfig config = new HikariConfig();
    config.setDriverClassName(driverClassName());
    config.setJdbcUrl(url);
    config.setUsername(username);
    config.setPassword(password);
    config.setMinimumIdle(minIdle);
    config.setMaximumPoolSize(maxPoolSize);
    if (validation) {
        config.setConnectionTestQuery(validationQuery());
    }
    config.setDataSourceProperties(props);
    return new HikariDataSource(config);
}
 
开发者ID:jkazama,项目名称:sample-boot-micro,代码行数:15,代码来源:OrmDataSourceProperties.java

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