Class SqlConnectionData

java.lang.Object
com.blueriq.component.api.connection.SqlConnectionData

public class SqlConnectionData extends Object
Class used by the Configurable connection manager to allow plugins to use the connections.
Since:
9.0
Author:
Danny Roest
  • 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

      public static final String 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 name
      jndi - the jndi name
      url - the jdbc url
      driver - the driver class name
      username - the username
      password - the password
      poolInitialSize - 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

      public String 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

      public DataSource getJndiDataSource()
      This method returns the datasource for the jndi name (if set).
      Returns:
      the datasource for the jndi name (if set)
    • getJndi

      public String getJndi()
    • getUrl

      public String getUrl()
    • getDriver

      public String getDriver()
    • getUsername

      public String getUsername()
    • getPassword

      public String 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

      public String 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