Class PoolableConnection

All Implemented Interfaces:
AutoCloseable, Connection, Wrapper, TrackedUse, PoolableConnectionMXBean

public class PoolableConnection extends DelegatingConnection<Connection> implements PoolableConnectionMXBean
A delegating connection that, rather than closing the underlying connection, returns itself to an ObjectPool when closed.
Since:
2.0
  • Field Details

    • MBEAN_SERVER

      private static MBeanServer MBEAN_SERVER
    • pool

      private final ObjectPool<PoolableConnection> pool
      The pool to which I should return.
    • jmxObjectName

      private final ObjectNameWrapper jmxObjectName
    • validationPreparedStatement

      private PreparedStatement validationPreparedStatement
    • lastValidationSql

      private String lastValidationSql
    • fatalSqlExceptionThrown

      private boolean fatalSqlExceptionThrown
      Indicate that unrecoverable SQLException was thrown when using this connection. Such a connection should be considered broken and not pass validation in the future.
    • disconnectionSqlCodes

      private final Collection<String> disconnectionSqlCodes
      SQL_STATE codes considered to signal fatal conditions. Overrides the defaults in Utils.DISCONNECTION_SQL_CODES (plus anything starting with Utils.DISCONNECTION_SQL_CODE_PREFIX).
    • fastFailValidation

      private final boolean fastFailValidation
      Whether or not to fast fail validation after fatal connection errors
  • Constructor Details

    • PoolableConnection

      public PoolableConnection(Connection conn, ObjectPool<PoolableConnection> pool, ObjectName jmxObjectName, Collection<String> disconnectSqlCodes, boolean fastFailValidation)
      Parameters:
      conn - my underlying connection
      pool - the pool to which I should return when closed
      jmxObjectName - JMX name
      disconnectSqlCodes - SQL_STATE codes considered fatal disconnection errors
      fastFailValidation - true means fatal disconnection errors cause subsequent validations to fail immediately (no attempt to run query or isValid)
    • PoolableConnection

      public PoolableConnection(Connection conn, ObjectPool<PoolableConnection> pool, ObjectName jmxName)
      Parameters:
      conn - my underlying connection
      pool - the pool to which I should return when closed
      jmxName - JMX name
  • Method Details