Interface AgroalConnectionPoolConfiguration.ConnectionValidator

Enclosing interface:
AgroalConnectionPoolConfiguration

public static interface AgroalConnectionPoolConfiguration.ConnectionValidator
Interface for custom connection validation strategies.
Author:
Luis Barreiro
  • Field Details

    • NETWORK_TIMEOUT_BUFFER

      static final Duration NETWORK_TIMEOUT_BUFFER
  • Method Details

    • defaultValidator

      The default validation strategy Connection.isValid(int)
    • defaultValidatorWithTimeout

      static AgroalConnectionPoolConfiguration.ConnectionValidator defaultValidatorWithTimeout(int timeout)
      The default validation strategy with a timeout (in seconds). If the timeout period expires before the operation completes, the connection is invalidated.
    • emptyValidator

      A validator that never invalidates connections.
    • sqlValidator

      static AgroalConnectionPoolConfiguration.ConnectionValidator sqlValidator(String sql, int timeoutSeconds)
      A validator that uses the provided SQL statement for validation with a timeout (in seconds). If the timeout period expires before the operation completes, the connection is invalidated. A timeout of 0 means no timeout.
    • sqlValidator

      static AgroalConnectionPoolConfiguration.ConnectionValidator sqlValidator(String sql, Duration queryTimeout)
      A validator that uses the provided SQL statement for validation with a query timeout. If the query timeout period expires before the operation completes, the connection is invalidated. A query timeout of zero means no timeout.
    • sqlValidator

      static AgroalConnectionPoolConfiguration.ConnectionValidator sqlValidator(String sql, Duration queryTimeout, Duration networkTimeout)
      A validator that uses the provided SQL statement for validation with a query timeout and a configurable network timeout. If the timeout period expires before the operation completes, the connection is invalidated. A timeout of zero means no timeout. The network timeout should be greater than the query timeout to allow the query timeout to cancel the statement cleanly before the network timeout forces the socket closed. A null network timeout will keep the connection's network timeout configuration unchanged
    • isValid

      boolean isValid(Connection connection)
      Returns:
      true if a connection is valid, false otherwise