- java.lang.Object
-
- io.rxmicro.config.Config
-
- io.rxmicro.data.sql.SQLDatabaseConfig
-
- io.rxmicro.data.sql.SQLPooledDatabaseConfig
-
public class SQLPooledDatabaseConfig extends SQLDatabaseConfig
Allows configuring SQL DB pool options.- Since:
- 0.1
- Author:
- nedis
- See Also:
Duration
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_ACQUIRE_RETRYDefault acquire retry.static intDEFAULT_INIT_POOL_SIZEDefault init pool size.static DurationDEFAULT_MAX_IDLE_DURATIONDefault max idle duration.static intDEFAULT_MAX_POOL_SIZEDefault max pool size.static StringDEFAULT_VALIDATION_QUERYDefault validation query.-
Fields inherited from class io.rxmicro.data.sql.SQLDatabaseConfig
DEFAULT_HOST
-
-
Constructor Summary
Constructors Constructor Description SQLPooledDatabaseConfig()Creates a pooled SQL config instance with default settings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetAcquireRetry()Returns the number of retries if the first connection acquire attempt fails.intgetInitialSize()Returns the initial pool size.DurationgetMaxAcquireTime()Returns the maximum time to acquire connection from pool.DurationgetMaxCreateConnectionTime()Returns the maximum time to create a new connection.DurationgetMaxIdleTime()Returns the maximum idle time of the connection in the pool.DurationgetMaxLifeTime()Returns the maximum lifetime of the connection in the pool.intgetMaxSize()Returns the maximum pool size.StringgetValidationQuery()Returns 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.SQLPooledDatabaseConfigsetAcquireRetry(int acquireRetry)Sets the number of retries if the first connection acquire attempt fails.SQLPooledDatabaseConfigsetConnectTimeout(Duration connectTimeout)Sets the connection timeout.SQLPooledDatabaseConfigsetDatabase(String database)Sets the database name.SQLPooledDatabaseConfigsetHost(String host)Sets the server host name.SQLPooledDatabaseConfigsetInitialSize(int initialSize)Sets the initial pool size.SQLPooledDatabaseConfigsetMaxAcquireTime(Duration maxAcquireTime)Sets the maximum time to acquire connection from pool.SQLPooledDatabaseConfigsetMaxCreateConnectionTime(Duration maxCreateConnectionTime)Sets the maximum time to create a new connection.SQLPooledDatabaseConfigsetMaxIdleTime(Duration maxIdleTime)Sets the maximum idle time of the connection in the pool.SQLPooledDatabaseConfigsetMaxLifeTime(Duration maxLifeTime)Sets the maximum lifetime of the connection in the pool.SQLPooledDatabaseConfigsetMaxSize(int maxSize)Sets the maximum pool size.SQLPooledDatabaseConfigsetOptions(Map<String,String> options)Sets the additional database options.SQLPooledDatabaseConfigsetPassword(CharSequence password)Sets the database password.SQLPooledDatabaseConfigsetPort(int port)Sets the server port.SQLPooledDatabaseConfigsetUser(String user)Sets the database username.SQLPooledDatabaseConfigsetValidationQuery(String validationQuery)Sets 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.-
Methods inherited from class io.rxmicro.data.sql.SQLDatabaseConfig
getConnectionString, getConnectTimeout, getDatabase, getHost, getOptions, getPassword, getPort, getUser, validate
-
-
-
-
Field Detail
-
DEFAULT_ACQUIRE_RETRY
public static final int DEFAULT_ACQUIRE_RETRY
Default acquire retry.- See Also:
- Constant Field Values
-
DEFAULT_INIT_POOL_SIZE
public static final int DEFAULT_INIT_POOL_SIZE
Default init pool size.- See Also:
- Constant Field Values
-
DEFAULT_MAX_POOL_SIZE
public static final int DEFAULT_MAX_POOL_SIZE
Default max pool size.- See Also:
- Constant Field Values
-
DEFAULT_MAX_IDLE_DURATION
public static final Duration DEFAULT_MAX_IDLE_DURATION
Default max idle duration.
-
DEFAULT_VALIDATION_QUERY
public static final String DEFAULT_VALIDATION_QUERY
Default validation query.- See Also:
- Constant Field Values
-
-
Method Detail
-
getAcquireRetry
public int getAcquireRetry()
Returns the number of retries if the first connection acquire attempt fails.Defaults to 2
- Returns:
- the number of retries if the first connection acquire attempt fails.
-
setAcquireRetry
@BuilderMethod public SQLPooledDatabaseConfig setAcquireRetry(int acquireRetry)
Sets the number of retries if the first connection acquire attempt fails.Defaults to 2
- Parameters:
acquireRetry- the number of retries if the first connection acquire attempt fails.- Returns:
- the reference to this
SQLPooledDatabaseConfiginstance
-
getInitialSize
public int getInitialSize()
Returns the initial pool size.Defaults to 3
- Returns:
- the initial pool size
-
setInitialSize
@BuilderMethod public SQLPooledDatabaseConfig setInitialSize(int initialSize)
Sets the initial pool size.Defaults to 3
- Parameters:
initialSize- the initial pool size- Returns:
- the reference to this
SQLPooledDatabaseConfiginstance
-
getMaxSize
public int getMaxSize()
Returns the maximum pool size.Defaults to 5
- Returns:
- the maximum pool size
-
setMaxSize
@BuilderMethod public SQLPooledDatabaseConfig setMaxSize(int maxSize)
Sets the maximum pool size.Defaults to 5
- Parameters:
maxSize- the maximum pool size- Returns:
- the reference to this
SQLPooledDatabaseConfiginstance
-
getValidationQuery
public String getValidationQuery()
Returns 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.- Returns:
- 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.
-
setValidationQuery
@BuilderMethod public SQLPooledDatabaseConfig setValidationQuery(String validationQuery)
Sets 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.- Parameters:
validationQuery- 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.- Returns:
- the reference to this
SQLPooledDatabaseConfiginstance
-
getMaxIdleTime
public Duration getMaxIdleTime()
Returns the maximum idle time of the connection in the pool.- Returns:
- the maximum idle time of the connection in the pool.
-
setMaxIdleTime
@BuilderMethod public SQLPooledDatabaseConfig setMaxIdleTime(Duration maxIdleTime)
Sets the maximum idle time of the connection in the pool.- Parameters:
maxIdleTime- the maximum idle time of the connection in the pool.- Returns:
- the reference to this
SQLPooledDatabaseConfiginstance
-
getMaxCreateConnectionTime
public Duration getMaxCreateConnectionTime()
Returns the maximum time to create a new connection.- Returns:
- the maximum time to create a new connection.
-
setMaxCreateConnectionTime
@BuilderMethod public SQLPooledDatabaseConfig setMaxCreateConnectionTime(Duration maxCreateConnectionTime)
Sets the maximum time to create a new connection.- Parameters:
maxCreateConnectionTime- the maximum time to create a new connection.- Returns:
- the reference to this
SQLPooledDatabaseConfiginstance
-
getMaxAcquireTime
public Duration getMaxAcquireTime()
Returns the maximum time to acquire connection from pool.- Returns:
- the maximum time to acquire connection from pool.
-
setMaxAcquireTime
@BuilderMethod public SQLPooledDatabaseConfig setMaxAcquireTime(Duration maxAcquireTime)
Sets the maximum time to acquire connection from pool.- Parameters:
maxAcquireTime- the maximum time to acquire connection from pool.- Returns:
- the reference to this
SQLPooledDatabaseConfiginstance
-
getMaxLifeTime
public Duration getMaxLifeTime()
Returns the maximum lifetime of the connection in the pool.- Returns:
- the maximum lifetime of the connection in the pool.
-
setMaxLifeTime
@BuilderMethod public SQLPooledDatabaseConfig setMaxLifeTime(Duration maxLifeTime)
Sets the maximum lifetime of the connection in the pool.- Parameters:
maxLifeTime- the maximum lifetime of the connection in the pool.- Returns:
- the reference to this
SQLPooledDatabaseConfiginstance
-
setHost
public SQLPooledDatabaseConfig setHost(String host)
Description copied from class:SQLDatabaseConfigSets the server host name.- Overrides:
setHostin classSQLDatabaseConfig- Parameters:
host- the server host name- Returns:
- the reference to this
SQLDatabaseConfiginstance
-
setPort
public SQLPooledDatabaseConfig setPort(int port)
Description copied from class:SQLDatabaseConfigSets the server port.- Overrides:
setPortin classSQLDatabaseConfig- Parameters:
port- the server port- Returns:
- the reference to this
SQLDatabaseConfiginstance
-
setUser
public SQLPooledDatabaseConfig setUser(String user)
Description copied from class:SQLDatabaseConfigSets the database username.- Overrides:
setUserin classSQLDatabaseConfig- Parameters:
user- the database username- Returns:
- the reference to this
SQLDatabaseConfiginstance
-
setPassword
public SQLPooledDatabaseConfig setPassword(CharSequence password)
Description copied from class:SQLDatabaseConfigSets the database password.- Overrides:
setPasswordin classSQLDatabaseConfig- Parameters:
password- the database password- Returns:
- the reference to this
SQLDatabaseConfiginstance
-
setDatabase
public SQLPooledDatabaseConfig setDatabase(String database)
Description copied from class:SQLDatabaseConfigSets the database name.- Overrides:
setDatabasein classSQLDatabaseConfig- Parameters:
database- the database name- Returns:
- the reference to this
SQLDatabaseConfiginstance
-
setOptions
public SQLPooledDatabaseConfig setOptions(Map<String,String> options)
Description copied from class:SQLDatabaseConfigSets the additional database options.- Overrides:
setOptionsin classSQLDatabaseConfig- Parameters:
options- the additional options- Returns:
- the reference to this
SQLDatabaseConfiginstance
-
setConnectTimeout
public SQLPooledDatabaseConfig setConnectTimeout(Duration connectTimeout)
Description copied from class:SQLDatabaseConfigSets the connection timeout.- Overrides:
setConnectTimeoutin classSQLDatabaseConfig- Parameters:
connectTimeout- the connection timeout- Returns:
- the reference to this
SQLDatabaseConfiginstance
-
-