Class GenericStatementContext.CancelQueryTask

java.lang.Object
java.util.TimerTask
org.apache.derby.impl.sql.conn.GenericStatementContext.CancelQueryTask
All Implemented Interfaces:
Runnable
Enclosing class:
GenericStatementContext

private static class GenericStatementContext.CancelQueryTask extends TimerTask
This is a TimerTask that is responsible for timing out statements, typically when an application has called Statement.setQueryTimeout(). When the application invokes execute() on a statement object, or fetches data on a ResultSet, a StatementContext object is allocated for the duration of the execution in the engine (until control is returned to the application). When the StatementContext object is assigned with setInUse(), a CancelQueryTask is scheduled if a timeout > 0 has been set.
  • Field Details

    • statementContext

      private StatementContext statementContext
      Reference to the StatementContext for the executing statement which might time out.
  • Constructor Details

    • CancelQueryTask

      public CancelQueryTask(StatementContext ctx)
      Initializes a new task for timing out a statement's execution. This does not schedule it for execution, the caller is responsible for calling Timer.schedule() with this object as parameter.
  • Method Details

    • run

      public void run()
      Invoked by a Timer class to cancel an executing statement. This method just sets a volatile flag in the associated StatementContext object by calling StatementContext.cancel(); it is the responsibility of the thread executing the statement to check this flag regularly.
      Specified by:
      run in interface Runnable
      Specified by:
      run in class TimerTask
    • forgetContext

      public void forgetContext()
      Stops this task and prevents it from cancelling a statement. Guarantees that after this method returns, the associated StatementContext object will not be tampered with by this task. Thus, the StatementContext object may safely be allocated to other executing statements.