public class HikariConfig extends Object implements HikariConfigMXBean
Constructor and Description |
---|
HikariConfig()
Default constructor
|
HikariConfig(Properties properties)
Construct a HikariConfig from the specified properties object.
|
HikariConfig(String propertyFileName)
Construct a HikariConfig from the specified property file name.
|
Modifier and Type | Method and Description |
---|---|
void |
addDataSourceProperty(String propertyName,
Object value) |
void |
addHealthCheckProperty(String key,
String value) |
void |
copyState(HikariConfig other) |
String |
getCatalog()
Get the default catalog name to be set on connections.
|
String |
getConnectionInitSql()
Get the SQL string that will be executed on all new connections when they are
created, before they are added to the pool.
|
String |
getConnectionTestQuery()
Get the SQL query to be executed to test the validity of connections.
|
long |
getConnectionTimeout()
Get the maximum number of milliseconds that a client will wait for a connection from the pool.
|
DataSource |
getDataSource()
Get the
DataSource that has been explicitly specified to be wrapped by the
pool. |
String |
getDataSourceClassName() |
String |
getDataSourceJNDI() |
Properties |
getDataSourceProperties() |
String |
getDriverClassName() |
Properties |
getHealthCheckProperties() |
Object |
getHealthCheckRegistry()
Get the Codahale HealthCheckRegistry, could be null.
|
long |
getIdleTimeout()
This property controls the maximum amount of time (in milliseconds) that a connection is allowed to sit
idle in the pool.
|
long |
getInitializationFailTimeout()
Get the pool initialization failure timeout.
|
String |
getJdbcUrl() |
long |
getLeakDetectionThreshold()
This property controls the amount of time that a connection can be out of the pool before a message is
logged indicating a possible connection leak.
|
int |
getMaximumPoolSize()
The property controls the maximum number of connections that HikariCP will keep in the pool,
including both idle and in-use connections.
|
long |
getMaxLifetime()
This property controls the maximum lifetime of a connection in the pool.
|
Object |
getMetricRegistry()
Get the Codahale MetricRegistry, could be null.
|
MetricsTrackerFactory |
getMetricsTrackerFactory() |
int |
getMinimumIdle()
The property controls the maximum size that the pool is allowed to reach, including both idle and in-use
connections.
|
String |
getPassword()
Get the default password to use for DataSource.getConnection(username, password) calls.
|
String |
getPoolName()
The name of the connection pool.
|
ScheduledExecutorService |
getScheduledExecutor()
Get the ScheduledExecutorService used for housekeeping.
|
ScheduledThreadPoolExecutor |
getScheduledExecutorService()
Deprecated.
|
ThreadFactory |
getThreadFactory()
Get the thread factory used to create threads.
|
String |
getTransactionIsolation() |
String |
getUsername()
Get the default username used for DataSource.getConnection(username, password) calls.
|
long |
getValidationTimeout()
Get the maximum number of milliseconds that the pool will wait for a connection to be validated as
alive.
|
boolean |
isAllowPoolSuspension()
Get the pool suspension behavior (allowed or disallowed).
|
boolean |
isAutoCommit()
Get the default auto-commit behavior of connections in the pool.
|
boolean |
isInitializationFailFast()
Deprecated.
|
boolean |
isIsolateInternalQueries() |
boolean |
isJdbc4ConnectionTest()
Deprecated.
|
boolean |
isReadOnly() |
boolean |
isRegisterMbeans() |
void |
setAllowPoolSuspension(boolean isAllowPoolSuspension)
Set whether or not pool suspension is allowed.
|
void |
setAutoCommit(boolean isAutoCommit)
Set the default auto-commit behavior of connections in the pool.
|
void |
setCatalog(String catalog)
Set the default catalog name to be set on connections.
|
void |
setConnectionInitSql(String connectionInitSql)
Set the SQL string that will be executed on all new connections when they are
created, before they are added to the pool.
|
void |
setConnectionTestQuery(String connectionTestQuery)
Set the SQL query to be executed to test the validity of connections.
|
void |
setConnectionTimeout(long connectionTimeoutMs)
Set the maximum number of milliseconds that a client will wait for a connection from the pool.
|
void |
setDataSource(DataSource dataSource)
Set a
DataSource for the pool to explicitly wrap. |
void |
setDataSourceClassName(String className) |
void |
setDataSourceJNDI(String jndiDataSource) |
void |
setDataSourceProperties(Properties dsProperties) |
void |
setDriverClassName(String driverClassName) |
void |
setHealthCheckProperties(Properties healthCheckProperties) |
void |
setHealthCheckRegistry(Object healthCheckRegistry)
Set a Codahale HealthCheckRegistry to use for HikariCP.
|
void |
setIdleTimeout(long idleTimeoutMs)
This property controls the maximum amount of time (in milliseconds) that a connection is allowed to sit
idle in the pool.
|
void |
setInitializationFailFast(boolean failFast)
Deprecated.
|
void |
setInitializationFailTimeout(long initializationFailTimeout)
Set the pool initialization failure timeout.
|
void |
setIsolateInternalQueries(boolean isolate) |
void |
setJdbc4ConnectionTest(boolean useIsValid)
Deprecated.
|
void |
setJdbcUrl(String jdbcUrl) |
void |
setLeakDetectionThreshold(long leakDetectionThresholdMs)
This property controls the amount of time that a connection can be out of the pool before a message is
logged indicating a possible connection leak.
|
void |
setMaximumPoolSize(int maxPoolSize)
The property controls the maximum size that the pool is allowed to reach, including both idle and in-use
connections.
|
void |
setMaxLifetime(long maxLifetimeMs)
This property controls the maximum lifetime of a connection in the pool.
|
void |
setMetricRegistry(Object metricRegistry)
Set a Codahale MetricRegistry to use for HikariCP.
|
void |
setMetricsTrackerFactory(MetricsTrackerFactory metricsTrackerFactory) |
void |
setMinimumIdle(int minIdle)
The property controls the minimum number of idle connections that HikariCP tries to maintain in the pool,
including both idle and in-use connections.
|
void |
setPassword(String password)
Set the default password to use for DataSource.getConnection(username, password) calls.
|
void |
setPoolName(String poolName)
Set the name of the connection pool.
|
void |
setReadOnly(boolean readOnly) |
void |
setRegisterMbeans(boolean register) |
void |
setScheduledExecutor(ScheduledExecutorService executor)
Set the ScheduledExecutorService used for housekeeping.
|
void |
setScheduledExecutorService(ScheduledThreadPoolExecutor executor)
Deprecated.
|
void |
setThreadFactory(ThreadFactory threadFactory)
Set the thread factory to be used to create threads.
|
void |
setTransactionIsolation(String isolationLevel)
Set the default transaction isolation level.
|
void |
setUsername(String username)
Set the default username used for DataSource.getConnection(username, password) calls.
|
void |
setValidationTimeout(long validationTimeoutMs)
Sets the maximum number of milliseconds that the pool will wait for a connection to be validated as
alive.
|
void |
validate() |
public HikariConfig()
public HikariConfig(Properties properties)
properties
- the name of the property filepublic HikariConfig(String propertyFileName)
propertyFileName
will first be treated as a path in the file-system, and if that fails the
Class.getResourceAsStream(propertyFileName) will be tried.propertyFileName
- the name of the property filepublic String getCatalog()
public void setCatalog(String catalog)
catalog
- the catalog name, or nullpublic String getConnectionTestQuery()
public void setConnectionTestQuery(String connectionTestQuery)
Connection.isValid()
method to test connection validity can
be more efficient on some databases and is recommended. See
setJdbc4ConnectionTest(boolean)
.connectionTestQuery
- a SQL query stringpublic String getConnectionInitSql()
public void setConnectionInitSql(String connectionInitSql)
connectionInitSql
- the SQL to execute on new connectionspublic long getConnectionTimeout()
DataSource.getConnection()
.getConnectionTimeout
in interface HikariConfigMXBean
public void setConnectionTimeout(long connectionTimeoutMs)
DataSource.getConnection()
.setConnectionTimeout
in interface HikariConfigMXBean
connectionTimeoutMs
- the connection timeout in millisecondspublic long getValidationTimeout()
getValidationTimeout
in interface HikariConfigMXBean
public void setValidationTimeout(long validationTimeoutMs)
setValidationTimeout
in interface HikariConfigMXBean
validationTimeoutMs
- the validation timeout in millisecondspublic DataSource getDataSource()
DataSource
that has been explicitly specified to be wrapped by the
pool.DataSource
instance, or nullpublic void setDataSource(DataSource dataSource)
DataSource
for the pool to explicitly wrap. This setter is not
available through property file based initialization.dataSource
- a specific DataSource
to be wrapped by the poolpublic String getDataSourceClassName()
public void setDataSourceClassName(String className)
public String getDataSourceJNDI()
public void setDataSourceJNDI(String jndiDataSource)
public Properties getDataSourceProperties()
public void setDataSourceProperties(Properties dsProperties)
public String getDriverClassName()
public void setDriverClassName(String driverClassName)
public long getIdleTimeout()
getIdleTimeout
in interface HikariConfigMXBean
public void setIdleTimeout(long idleTimeoutMs)
setIdleTimeout
in interface HikariConfigMXBean
idleTimeoutMs
- the idle timeout in millisecondspublic String getJdbcUrl()
public void setJdbcUrl(String jdbcUrl)
public boolean isAutoCommit()
public void setAutoCommit(boolean isAutoCommit)
isAutoCommit
- the desired auto-commit default for connectionspublic boolean isAllowPoolSuspension()
public void setAllowPoolSuspension(boolean isAllowPoolSuspension)
isAllowPoolSuspension
- the desired pool suspension allowancepublic long getInitializationFailTimeout()
#setInitializationFailTimeout(long)
for details.setInitializationFailTimeout(long)
public void setInitializationFailTimeout(long initializationFailTimeout)
HikariDataSource
is constructed with a HikariConfig
,
or when HikariDataSource
is constructed using the no-arg constructor
and HikariDataSource.getConnection()
is called.
DataSource#getConnection()
may encounter
exceptions.PoolInitializationException
will be thrown.
connectionTimeout
or
validationTimeout
; they will be honored before this timeout is applied. The
default value is one millisecond.initializationFailTimeout
- the number of milliseconds before the
pool initialization fails, or 0 or less to skip the initialization
check.@Deprecated public boolean isInitializationFailFast()
@Deprecated public void setInitializationFailFast(boolean failFast)
failFast
- true if the pool should fail if the minimum connections cannot be createdpublic boolean isIsolateInternalQueries()
public void setIsolateInternalQueries(boolean isolate)
@Deprecated public boolean isJdbc4ConnectionTest()
@Deprecated public void setJdbc4ConnectionTest(boolean useIsValid)
public MetricsTrackerFactory getMetricsTrackerFactory()
public void setMetricsTrackerFactory(MetricsTrackerFactory metricsTrackerFactory)
public Object getMetricRegistry()
public void setMetricRegistry(Object metricRegistry)
metricRegistry
- the Codahale MetricRegistry to setpublic Object getHealthCheckRegistry()
public void setHealthCheckRegistry(Object healthCheckRegistry)
healthCheckRegistry
- the Codahale HealthCheckRegistry to setpublic Properties getHealthCheckProperties()
public void setHealthCheckProperties(Properties healthCheckProperties)
public boolean isReadOnly()
public void setReadOnly(boolean readOnly)
public boolean isRegisterMbeans()
public void setRegisterMbeans(boolean register)
public long getLeakDetectionThreshold()
getLeakDetectionThreshold
in interface HikariConfigMXBean
public void setLeakDetectionThreshold(long leakDetectionThresholdMs)
setLeakDetectionThreshold
in interface HikariConfigMXBean
leakDetectionThresholdMs
- the connection leak detection threshold in millisecondspublic long getMaxLifetime()
getMaxLifetime
in interface HikariConfigMXBean
public void setMaxLifetime(long maxLifetimeMs)
setMaxLifetime
in interface HikariConfigMXBean
maxLifetimeMs
- the maximum connection lifetime in millisecondspublic int getMaximumPoolSize()
getMaximumPoolSize
in interface HikariConfigMXBean
public void setMaximumPoolSize(int maxPoolSize)
When the pool reaches this size, and no idle connections are available, calls to getConnection() will block for up to connectionTimeout milliseconds before timing out.
setMaximumPoolSize
in interface HikariConfigMXBean
maxPoolSize
- the maximum number of connections in the poolpublic int getMinimumIdle()
When the pool reaches this size, and no idle connections are available, calls to getConnection() will block for up to connectionTimeout milliseconds before timing out.
getMinimumIdle
in interface HikariConfigMXBean
public void setMinimumIdle(int minIdle)
setMinimumIdle
in interface HikariConfigMXBean
minIdle
- the minimum number of idle connections in the pool to maintainpublic String getPassword()
public void setPassword(String password)
setPassword
in interface HikariConfigMXBean
password
- the passwordpublic String getPoolName()
getPoolName
in interface HikariConfigMXBean
public void setPoolName(String poolName)
poolName
- the name of the connection pool to use@Deprecated public ScheduledThreadPoolExecutor getScheduledExecutorService()
@Deprecated public void setScheduledExecutorService(ScheduledThreadPoolExecutor executor)
executor
- the ScheduledExecutorServicepublic ScheduledExecutorService getScheduledExecutor()
public void setScheduledExecutor(ScheduledExecutorService executor)
executor
- the ScheduledExecutorServicepublic String getTransactionIsolation()
public void setTransactionIsolation(String isolationLevel)
Connection
class, eg.
TRANSACTION_REPEATABLE_READ
.isolationLevel
- the name of the isolation levelpublic String getUsername()
public void setUsername(String username)
setUsername
in interface HikariConfigMXBean
username
- the usernamepublic ThreadFactory getThreadFactory()
public void setThreadFactory(ThreadFactory threadFactory)
threadFactory
- the thread factory (setting to null causes the default thread factory to be used)public void validate()
public void copyState(HikariConfig other)
Copyright © 2017 Zaxxer.com. All Rights Reserved.