use of com.zaxxer.hikari.HikariConfig in project HikariCP by brettwooldridge.
the class TestValidation method validateLoadProperties.
@Test
public void validateLoadProperties() {
System.setProperty("hikaricp.configurationFile", "/propfile1.properties");
HikariConfig config = newHikariConfig();
System.clearProperty("hikaricp.configurationFile");
assertEquals(5, config.getMinimumIdle());
}
use of com.zaxxer.hikari.HikariConfig in project jphp by jphp-compiler.
the class PSqlDriverManager method getPool.
@Signature
public static PSqlConnectionPool getPool(Environment env, String url, String driverName, @Nullable Properties properties) throws SQLException {
HikariConfig config = new HikariConfig(properties == null ? new Properties() : properties);
if (config.getDataSourceClassName() == null) {
config.setDataSourceClassName(dataSourceClasses.get(driverName));
}
HikariDataSource pool = new HikariDataSource(config);
pool.setDriverClassName(_getDriverClass(driverName));
pool.setJdbcUrl("jdbc:" + url);
return new PSqlConnectionPool(env, pool);
}
use of com.zaxxer.hikari.HikariConfig in project torodb by torodb.
the class AbstractDbBackendService method createPooledDataSource.
private HikariDataSource createPooledDataSource(ConfigurationT configuration, String poolName, int poolSize, TransactionIsolationLevel transactionIsolationLevel, boolean readOnly) {
HikariConfig hikariConfig = new HikariConfig();
// Delegate database-specific setting of connection parameters and any specific configuration
hikariConfig.setDataSource(getConfiguredDataSource(configuration, poolName));
// Apply ToroDB-specific datasource configuration
hikariConfig.setConnectionTimeout(configuration.getConnectionPoolTimeout());
hikariConfig.setPoolName(poolName);
hikariConfig.setMaximumPoolSize(poolSize);
hikariConfig.setTransactionIsolation(transactionIsolationLevel.name());
hikariConfig.setReadOnly(readOnly);
/*
* TODO: implement to add metric support. See
* https://github.com/brettwooldridge/HikariCP/wiki/Codahale-Metrics
* hikariConfig.setMetricRegistry(...);
*/
LOGGER.info("Created pool {} with size {} and level {}", poolName, poolSize, transactionIsolationLevel.name());
return new HikariDataSource(hikariConfig);
}
use of com.zaxxer.hikari.HikariConfig in project opennms by OpenNMS.
the class HikariCPConnectionFactory method initializePool.
/* (non-Javadoc)
* @see org.opennms.core.db.BaseConnectionFactory#initializePool(org.opennms.netmgt.config.opennmsDataSources.JdbcDataSource)
*/
// TODO Enable and configure MetricRegistry
@Override
protected void initializePool(final JdbcDataSource dataSource) throws SQLException {
final Properties properties = new Properties();
for (final Param parameter : dataSource.getParamCollection()) {
properties.setProperty(parameter.getName(), parameter.getValue());
}
final HikariConfig config = new HikariConfig(properties);
config.setPoolName(dataSource.getName());
config.setJdbcUrl(dataSource.getUrl());
config.setUsername(dataSource.getUserName());
config.setPassword(dataSource.getPassword());
config.setDriverClassName(dataSource.getClassName());
// NMS-9387: Block indefinitely when waiting for a connection
config.setConnectionTimeout(0);
// For JMX Monitoring
config.setRegisterMbeans(true);
config.validate();
m_pool = new HikariDataSource(config);
}
use of com.zaxxer.hikari.HikariConfig in project AuthMeReloaded by AuthMe.
the class LoginSecurityConverterTest method initializeMySqlTable.
private Connection initializeMySqlTable() throws IOException, SQLException {
File sqlInitFile = TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "datasource/converter/loginsecurity.sql");
String initStatement = new String(Files.readAllBytes(sqlInitFile.toPath()));
HikariConfig config = new HikariConfig();
config.setDataSourceClassName("org.h2.jdbcx.JdbcDataSource");
config.setConnectionTestQuery("VALUES 1");
config.addDataSourceProperty("URL", "jdbc:h2:mem:test");
config.addDataSourceProperty("user", "sa");
config.addDataSourceProperty("password", "sa");
HikariDataSource ds = new HikariDataSource(config);
Connection connection = ds.getConnection();
try (Statement st = connection.createStatement()) {
st.execute("DROP TABLE IF EXISTS authme");
st.execute(initStatement);
}
return connection;
}
Aggregations