Class Driver.ConnectTask

java.lang.Object
org.postgresql.Driver.ConnectTask
All Implemented Interfaces:
Runnable
Enclosing class:
Driver

private static class Driver.ConnectTask extends Object implements Runnable
Perform a connect in a separate thread; supports getting the results from the original thread while enforcing a login timeout.

If the caller times out or is interrupted, we mark the attempt as abandoned and try to cancel the worker thread. Cancellation is best-effort: if the connection attempt does not stop immediately, the worker closes any connection it manages to establish after abandonment so that it does not leak.

  • Field Details

  • Constructor Details

  • Method Details

    • run

      public void run()
      Specified by:
      run in interface Runnable
    • getResult

      Connection getResult(long timeout) throws SQLException
      Get the connection result from this (assumed running) task. If the timeout is reached without a result being available, a SQLException is thrown.
      Parameters:
      timeout - timeout in milliseconds
      Returns:
      the new connection, if successful
      Throws:
      SQLException - if a connection error occurs or the timeout is reached
    • abandon

      private void abandon()
    • closeConnection

      private static void closeConnection(Connection conn)