public class HikariConfig extends Object implements HikariConfigMBean
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) |
String |
getCatalog()
Get the default catalog name to be set on connections.
|
String |
getConnectionCustomizerClassName()
Get the name of the connection customizer class to instantiate and execute
on all new 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()
This is for "legacy" databases that do not support the JDBC4
Connection.isValid() API. |
DataSource |
getDataSource()
Get the
DataSource that has been explicitly specified to be wrapped by the
pool. |
String |
getDataSourceClassName() |
String |
getDataSourceJNDI() |
Properties |
getDataSourceProperties() |
long |
getIdleTimeout()
This property controls the maximum amount of time (in milliseconds) that a connection is allowed to sit
idle in the pool.
|
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.
|
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.
|
int |
getTransactionIsolation() |
String |
getUsername()
Get the default username used for DataSource.getConnection(username, password) calls.
|
boolean |
isAutoCommit()
Get the default auto-commit behavior of connections in the pool.
|
boolean |
isInitializationFailFast()
Get whether or not the construction of the pool should throw an exception
if the minimum number of connections cannot be created.
|
boolean |
isIsolateInternalQueries() |
boolean |
isJdbc4ConnectionTest() |
boolean |
isReadOnly() |
boolean |
isRecordMetrics() |
boolean |
isRegisterMbeans() |
void |
setAcquireIncrement(int acquireIncrement)
Deprecated.
|
void |
setAcquireRetries(int acquireRetries)
Deprecated.
|
void |
setAcquireRetryDelay(long acquireRetryDelayMs)
Deprecated.
|
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 |
setConnectionCustomizerClassName(String connectionCustomizerClassName)
Set the name of the connection customizer class to instantiate and execute
on all new 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)
This is for "legacy" databases that do not support the JDBC4 {code Connection.isValid()} API.
|
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 |
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)
Set whether or not the construction of the pool should throw an exception
if the minimum number of connections cannot be created.
|
void |
setIsolateInternalQueries(boolean isolate) |
void |
setJdbc4ConnectionTest(boolean useIsValid) |
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 |
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 |
setMinimumPoolSize(int minPoolSize)
Deprecated.
|
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 |
setRecordMetrics(boolean recordMetrics)
Deprecated.
|
void |
setRegisterMbeans(boolean register) |
void |
setTransactionIsolation(String isolationLevel)
Set the default transaction isolation level.
|
void |
setUseInstrumentation(boolean useInstrumentation)
Deprecated.
|
void |
setUsername(String username)
Set the default username used for DataSource.getConnection(username, password) calls.
|
void |
validate() |
public HikariConfig()
public HikariConfig(Properties properties)
properties
- the name of the property filepublic HikariConfig(String propertyFileName)
propertyFileName
- the name of the property file@Deprecated public void setAcquireIncrement(int acquireIncrement)
@Deprecated public void setAcquireRetries(int acquireRetries)
@Deprecated public void setAcquireRetryDelay(long acquireRetryDelayMs)
public String getCatalog()
public void setCatalog(String catalog)
catalog
- the catalog name, or nullpublic String getConnectionCustomizerClassName()
public void setConnectionCustomizerClassName(String connectionCustomizerClassName)
connectionCustomizerClassName
- the name of the customizer classpublic 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()
Connection.isValid()
API. This is the
query that will be executed just before a connection is given to you from the pool to validate that
the connection to the database is still alive. It is database dependent and should be a query that
takes very little processing by the database (eg. "VALUES 1"). See the {code getJdbc4ConnectionTest()} property
for a more efficent alive test. One of either this property or jdbc4ConnectionTest must be specified.getConnectionTimeout
in interface HikariConfigMBean
public void setConnectionTimeout(long connectionTimeoutMs)
setJdbc4ConnectionTest()
property
for a more efficent alive test. One of either this property or jdbc4ConnectionTest must be specified.setConnectionTimeout
in interface HikariConfigMBean
connectionTimeoutMs
- the connection 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 void setDriverClassName(String driverClassName)
public long getIdleTimeout()
getIdleTimeout
in interface HikariConfigMBean
public void setIdleTimeout(long idleTimeoutMs)
setIdleTimeout
in interface HikariConfigMBean
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 isInitializationFailFast()
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)
public boolean isJdbc4ConnectionTest()
public void setJdbc4ConnectionTest(boolean useIsValid)
public boolean isReadOnly()
public void setReadOnly(boolean readOnly)
public boolean isRecordMetrics()
@Deprecated public void setRecordMetrics(boolean recordMetrics)
recordMetrics
- true
if metrics should be recordedpublic boolean isRegisterMbeans()
public void setRegisterMbeans(boolean register)
public long getLeakDetectionThreshold()
getLeakDetectionThreshold
in interface HikariConfigMBean
public void setLeakDetectionThreshold(long leakDetectionThresholdMs)
setLeakDetectionThreshold
in interface HikariConfigMBean
leakDetectionThresholdMs
- the connection leak detection threshold in milliseconds@Deprecated public void setUseInstrumentation(boolean useInstrumentation)
public long getMaxLifetime()
getMaxLifetime
in interface HikariConfigMBean
public void setMaxLifetime(long maxLifetimeMs)
setMaxLifetime
in interface HikariConfigMBean
maxLifetimeMs
- the maximum connection lifetime in milliseconds@Deprecated public void setMinimumPoolSize(int minPoolSize)
public int getMaximumPoolSize()
getMaximumPoolSize
in interface HikariConfigMBean
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 HikariConfigMBean
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 HikariConfigMBean
public void setMinimumIdle(int minIdle)
setMinimumIdle
in interface HikariConfigMBean
minIdle
- the minimum number of idle connections in the pool to maintainpublic String getPassword()
public void setPassword(String password)
password
- the passwordpublic String getPoolName()
getPoolName
in interface HikariConfigMBean
public void setPoolName(String poolName)
poolName
- the name of the connection pool to usepublic int 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)
username
- the usernamepublic void validate()
Copyright © 2014 Zaxxer.com. All rights reserved.