Class SqlConnectionData
java.lang.Object
com.blueriq.component.api.connection.SqlConnectionData
Class used by the Configurable connection manager to allow plugins to use the connections.
- Since:
- 9.0
- Author:
- Danny Roest
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
static final int
static final int
static final int
static final int
static final long
static final int
static final boolean
static final boolean
static final boolean
static final long
static final String
static final int
protected static final org.slf4j.Logger
-
Constructor Summary
ConstructorsConstructorDescriptionSqlConnectionData
(String name, String jndi, String url, String driver, String username, String password, String poolInitialSize, String poolMaxTotal, String poolMaxIdle, String poolMinIdle, String poolMaxWait, String validationQuery, String validationQueryTimeout, String testOnBorrow, String testOnReturn, String testWhileIdle, String timeBetweenEvictionRunsMillis, String numTestsPerEvictionRun, String minEvictableIdleTimeMillis) Constructs a new SqlConnection data. -
Method Summary
Modifier and TypeMethodDescriptiongetJndi()
This method returns the datasource for the jndi name (if set).long
The minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any).getName()
This method returns the name of the the connectionint
The number of objects to examine during each run of the idle object evictor thread (if any).int
The initial number of connections that are created when the pool is started.int
The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit.int
The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit.long
The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception, or -1 to wait indefinitely.int
The minimum number of connections that can remain idle in the pool, without extra ones being created, or zero to create none.long
The number of milliseconds to sleep between runs of the idle object evictor thread.getUrl()
The SQL query that will be used to validate connections from this pool before returning them to the caller.int
The timeout in seconds before connection validation queries fail.boolean
isJndi()
This method returns true if the connection is configured via jndi,boolean
The indication of whether objects will be validated before being borrowed from the pool.boolean
The indication of whether objects will be validated before being returned to the pool.boolean
The indication of whether objects will be validated by the idle object evictor (if any).
-
Field Details
-
DEFAULT_POOL_INITIAL_SIZE
public static final int DEFAULT_POOL_INITIAL_SIZE- See Also:
-
DEFAULT_POOL_MAX_TOTAL
public static final int DEFAULT_POOL_MAX_TOTAL- See Also:
-
DEFAULT_POOL_MAX_IDLE
public static final int DEFAULT_POOL_MAX_IDLE- See Also:
-
DEFAULT_POOL_MIN_IDLE
public static final int DEFAULT_POOL_MIN_IDLE- See Also:
-
DEFAULT_POOL_MAX_WAIT
public static final long DEFAULT_POOL_MAX_WAIT- See Also:
-
DEFAULT_VALIDATION_QUERY
- See Also:
-
DEFAULT_VALIDATION_QUERY_TIMEOUT
public static final int DEFAULT_VALIDATION_QUERY_TIMEOUT- See Also:
-
DEFAULT_TEST_ON_BORROW
public static final boolean DEFAULT_TEST_ON_BORROW- See Also:
-
DEFAULT_TEST_ON_RETURN
public static final boolean DEFAULT_TEST_ON_RETURN- See Also:
-
DEFAULT_TEST_WHILE_IDLE
public static final boolean DEFAULT_TEST_WHILE_IDLE- See Also:
-
DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS- See Also:
-
DEFAULT_NUM_TESTS_PER_EVICTION_RUN
public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN- See Also:
-
DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS- See Also:
-
LOG
protected static final org.slf4j.Logger LOG
-
-
Constructor Details
-
SqlConnectionData
public SqlConnectionData(String name, String jndi, String url, String driver, String username, String password, String poolInitialSize, String poolMaxTotal, String poolMaxIdle, String poolMinIdle, String poolMaxWait, String validationQuery, String validationQueryTimeout, String testOnBorrow, String testOnReturn, String testWhileIdle, String timeBetweenEvictionRunsMillis, String numTestsPerEvictionRun, String minEvictableIdleTimeMillis) Constructs a new SqlConnection data. Either jndi or jdbc should be configured.- Parameters:
name
- the connection namejndi
- the jndi nameurl
- the jdbc urldriver
- the driver class nameusername
- the usernamepassword
- the passwordpoolInitialSize
- The initial number of connections that are created when the pool is started. Default 0.poolMaxTotal
- The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit. Default 8.poolMaxIdle
- The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit. Default 8.poolMinIdle
- The minimum number of connections that can remain idle in the pool, without extra ones being created, or zero to create none. Default 0.poolMaxWait
- The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception, or -1 to wait indefinitely. Default -1L.validationQuery
- The query executed to validate if the connection is still valid.validationQueryTimeout
- The maximum number of milliseconds to wait for a result from the validationQuery.testOnBorrow
- Should the validationQuery be executed every time the connection is taken from the pool (boolean)testOnReturn
- Should the validationQuery be executed every time the connection is returned to the pool (boolean)testWhileIdle
- The indication of whether objects will be validated by the idle object evictor (if any). If an object fails to validate, it will be dropped from the pool.timeBetweenEvictionRunsMillis
- Sets the number of milliseconds to sleep between runs of the idle object evictor thread.numTestsPerEvictionRun
- Sets the maximum number of objects to examine during each run (if any) of the idle object evictor thread.minEvictableIdleTimeMillis
- The minimum amount of time an object may sit idle in the pool before it is eligible for eviction by the idle object evictor.
-
-
Method Details
-
getName
This method returns the name of the the connection- Returns:
- The name, never null.
-
isJndi
public boolean isJndi()This method returns true if the connection is configured via jndi,- Returns:
- true if the connection is configured via jndi.
-
getJndiDataSource
This method returns the datasource for the jndi name (if set).- Returns:
- the datasource for the jndi name (if set)
-
getJndi
-
getUrl
-
getDriver
-
getUsername
-
getPassword
-
getPoolInitialSize
public int getPoolInitialSize()The initial number of connections that are created when the pool is started.- Returns:
- the pool initial connection size
-
getPoolMaxTotal
public int getPoolMaxTotal()The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit.- Returns:
- the pool max connection size
-
getPoolMaxIdle
public int getPoolMaxIdle()The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit.- Returns:
- the pool max idle connections
-
getPoolMinIdle
public int getPoolMinIdle()The minimum number of connections that can remain idle in the pool, without extra ones being created, or zero to create none.- Returns:
- the minimal ideal connections in the pool
-
getPoolMaxWait
public long getPoolMaxWait()The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception, or -1 to wait indefinitely.- Returns:
- the maximum wait time of connections in the pool
-
getValidationQuery
The SQL query that will be used to validate connections from this pool before returning them to the caller. If specified, this query MUST be an SQL SELECT statement that returns at least one row. If not specified, connections will be validation by calling the isValid() method.- Returns:
- the validation query
-
getValidationQueryTimeout
public int getValidationQueryTimeout()The timeout in seconds before connection validation queries fail. If set to a positive value, this value is passed to the driver via the setQueryTimeout method of the Statement used to execute the validation query.- Returns:
- the max time the validation query can take
-
isTestOnBorrow
public boolean isTestOnBorrow()The indication of whether objects will be validated before being borrowed from the pool. If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another.- Returns:
- boolean indicating if the connection should be tested on borrow
-
isTestOnReturn
public boolean isTestOnReturn()The indication of whether objects will be validated before being returned to the pool.- Returns:
- boolean indicating if the connection should be tested when returned to the pool
-
isTestWhileIdle
public boolean isTestWhileIdle()The indication of whether objects will be validated by the idle object evictor (if any). If an object fails to validate, it will be dropped from the pool.- Returns:
- boolean indicating if the connection should be tested when idle
-
getTimeBetweenEvictionRunsMillis
public long getTimeBetweenEvictionRunsMillis()The number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive, no idle object evictor thread will be run.- Returns:
- the time between eviction runs in milliseconds
-
getNumTestsPerEvictionRun
public int getNumTestsPerEvictionRun()The number of objects to examine during each run of the idle object evictor thread (if any).- Returns:
- the number of connections that should be tested in a eviction run
-
getMinEvictableIdleTimeMillis
public long getMinEvictableIdleTimeMillis()The minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any).- Returns:
- minimal amount of time a connection should be in the pool before eviction
-