Package org.pjdbc.sql

Interface PjdbcEventListener

All Known Implementing Classes:
DebugEventListener

public interface PjdbcEventListener
Listener interface for PJDBC driver events.

Implementations can monitor driver behavior without modifying driver code. Register listeners via:

All callback methods have default empty implementations so listeners only need to override the events they care about.

Example usage:


 PjdbcListeners.register(new PjdbcEventListener() {
     @Override
     public void onRetry(String sql, SQLException cause, int attempt, long delayMs) {
         logger.warn("Retry attempt {} after {}ms: {}", attempt, delayMs, cause.getMessage());
     }
 });
 
Since:
2.2.0
  • Method Details

    • onRetry

      default void onRetry(String sql, SQLException cause, int attempt, long delayMs)
      Called when a retry is about to be attempted.
      Parameters:
      sql - the SQL statement being retried (may be null for non-SQL operations)
      cause - the exception that triggered the retry
      attempt - the retry attempt number (1 for first retry, 2 for second, etc.)
      delayMs - the delay in milliseconds before the retry will be attempted
    • onCircuitBreakerStateChange

      default void onCircuitBreakerStateChange(String name, String oldState, String newState)
      Called when a circuit breaker changes state.
      Parameters:
      name - the circuit breaker name
      oldState - the previous state (CLOSED, OPEN, or HALF_OPEN)
      newState - the new state
    • onSqlTransformed

      default void onSqlTransformed(String original, String transformed)
      Called when SQL is transformed by a filter driver.
      Parameters:
      original - the original SQL statement
      transformed - the transformed SQL statement
    • onFederatedQuery

      default void onFederatedQuery(String sql, List<String> targetUrls)
      Called when a query is executed against multiple federated databases.
      Parameters:
      sql - the SQL statement being executed
      targetUrls - the JDBC URLs of the target databases
    • onCircuitBreakerRejection

      default void onCircuitBreakerRejection(String name, String state)
      Called when a request is rejected by a circuit breaker.
      Parameters:
      name - the circuit breaker name
      state - the current circuit breaker state
    • onChaosInjected

      default void onChaosInjected(String type, String sql, String details)
      Called when chaos injection occurs (for ChaosDriver).
      Parameters:
      type - the type of chaos injected (e.g., "delay", "exception", "timeout")
      sql - the SQL statement affected (may be null)
      details - additional details about the chaos injection