Interface ConfigurationStage
- All Known Implementing Classes:
DataSourceCreator
public interface ConfigurationStage
Configuration stage, which is used to configura a
HikariConfig.-
Method Summary
Modifier and TypeMethodDescriptioncom.zaxxer.hikari.HikariDataSourcebuild()Create a new hikari data sourceSet the default schema name to be set on connections.usingPassword(String password) Set the default password to use for DataSource.getConnection(username, password) calls.usingUsername(String username) Set the default username used for DataSource.getConnection(username, password) calls.withAutoCommit(boolean isAutoCommit) Set the default auto-commit behavior of connections in the pool.withConnectionTimeout(long connectionTimeoutMs) Set the maximum number of milliseconds that a client will wait for a connection from the pool.withDataSourceClassName(Class<? extends DataSource> className) Set the fully qualified class name of the JDBCDataSourcethat will be used create Connections.withIdleTimeout(long idleTimeoutMs) This property controls the maximum amount of time (in milliseconds) that a connection is allowed to sit idle in the pool.withKeepaliveTime(long keepaliveTimeMs) This property controls the keepalive interval for a connection in the pool.withMaximumPoolSize(int maxPoolSize) The property controls the maximum size that the pool is allowed to reach, including both idle and in-use connections.withMaxLifetime(long maxLifetimeMs) This property controls the maximum lifetime of a connection in the pool.withMinimumIdle(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.withPoolName(String poolName) Set the name of the connection pool.Set the ScheduledExecutorService used for housekeeping.withThreadFactory(ThreadFactory threadFactory) Set the thread factory to be used to create threads.
-
Method Details
-
withConnectionTimeout
Set the maximum number of milliseconds that a client will wait for a connection from the pool. If this time is exceeded without a connection becoming available, a SQLException will be thrown fromDataSource.getConnection().- Parameters:
connectionTimeoutMs- the connection timeout in milliseconds- Returns:
- Configuration Stage with value set.
-
withIdleTimeout
This property controls the maximum amount of time (in milliseconds) that a connection is allowed to sit idle in the pool. Whether a connection is retired as idle or not is subject to a maximum variation of +30 seconds, and average variation of +15 seconds. A connection will never be retired as idle before this timeout. A value of 0 means that idle connections are never removed from the pool.- Parameters:
idleTimeoutMs- the idle timeout in milliseconds- Returns:
- Configuration Stage with value set.
-
withMaxLifetime
This property controls the maximum lifetime of a connection in the pool. When a connection reaches this timeout, even if recently used, it will be retired from the pool. An in-use connection will never be retired, only when it is idle will it be removed.- Parameters:
maxLifetimeMs- the maximum connection lifetime in milliseconds- Returns:
- Configuration Stage with value set.
-
withMaximumPoolSize
The property controls the maximum size that the pool is allowed to reach, including both idle and in-use connections. Basically this value will determine the maximum number of actual connections to the database backend.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.
- Parameters:
maxPoolSize- the maximum number of connections in the pool- Returns:
- Configuration Stage with value set.
-
withMinimumIdle
The property controls the minimum number of idle connections that HikariCP tries to maintain in the pool, including both idle and in-use connections. If the idle connections dip below this value, HikariCP will make a best effort to restore them quickly and efficiently.- Parameters:
minIdle- the minimum number of idle connections in the pool to maintain- Returns:
- Configuration Stage with value set.
-
usingPassword
Set the default password to use for DataSource.getConnection(username, password) calls.- Parameters:
password- the password- Returns:
- Configuration Stage with value set.
-
usingUsername
Set the default username used for DataSource.getConnection(username, password) calls.- Parameters:
username- the username- Returns:
- Configuration Stage with value set.
-
withDataSourceClassName
Set the fully qualified class name of the JDBCDataSourcethat will be used create Connections.- Parameters:
className- the fully qualified name of the JDBCDataSourceclass- Returns:
- Configuration Stage with value set.
-
withAutoCommit
Set the default auto-commit behavior of connections in the pool.- Parameters:
isAutoCommit- the desired auto-commit default for connections- Returns:
- Configuration Stage with value set.
-
withKeepaliveTime
This property controls the keepalive interval for a connection in the pool. An in-use connection will never be tested by the keepalive thread, only when it is idle will it be tested.- Parameters:
keepaliveTimeMs- the interval in which connections will be tested for aliveness, thus keeping them alive by the act of checking. Value is in milliseconds, default is 0 (disabled).- Returns:
- Configuration Stage with value set.
-
withPoolName
Set the name of the connection pool. This is primarily used for the MBean to uniquely identify the pool configuration.- Parameters:
poolName- the name of the connection pool to use- Returns:
- Configuration Stage with value set.
-
withScheduledExecutor
Set the ScheduledExecutorService used for housekeeping.- Parameters:
executor- the ScheduledExecutorService- Returns:
- Configuration Stage with value set.
-
forSchema
Set the default schema name to be set on connections.- Parameters:
schema- the name of the default schema- Returns:
- Configuration Stage with value set.
-
withThreadFactory
Set the thread factory to be used to create threads.- Parameters:
threadFactory- the thread factory (setting to null causes the default thread factory to be used)- Returns:
- Configuration Stage with value set.
-
build
com.zaxxer.hikari.HikariDataSource build()Create a new hikari data source- Returns:
- hikari data source instance
-