Package com.databricks.jdbc.dbclient.impl.common

## Class TimeoutHandler

- java.lang.Object
- - com.databricks.jdbc.dbclient.impl.common.TimeoutHandler

    public class TimeoutHandler
    extends Object

Utility class to handle statement execution timeouts.

### Constructor Summary

Constructors
`TimeoutHandler​(int timeoutSeconds, String operationDescription, Runnable onTimeoutAction, DatabricksDriverErrorCode internalErrorCode)` Creates a new timeout handler with the provided parameters.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `checkTimeout()` Checks if the operation has timed out.
`static TimeoutHandler` `forStatement​(int timeoutSeconds, StatementId statementId, IDatabricksClient client, DatabricksDriverErrorCode internalErrorCode)` Factory method to create a timeout handler for a databricks client with a statement ID.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### TimeoutHandler

    public TimeoutHandler​(int timeoutSeconds,
                          String operationDescription,
                          Runnable onTimeoutAction,
                          DatabricksDriverErrorCode internalErrorCode)

Creates a new timeout handler with the provided parameters.

Parameters:
  `timeoutSeconds` - Timeout in seconds, 0 means no timeout
  `operationDescription` - Description of the operation for logging
  `onTimeoutAction` - Runnable to call when a timeout occurs
  `internalErrorCode` - Internal driver error code to annotate timeout exceptions

### Method Detail

#### checkTimeout

    public void checkTimeout()
                      throws DatabricksTimeoutException

Checks if the operation has timed out. If a timeout occurs, it attempts to execute the timeout action and throws a DatabricksTimeoutException.

Throws:
  `DatabricksTimeoutException` - if the operation timed out

#### forStatement

    public static TimeoutHandler forStatement​(int timeoutSeconds,
                                              StatementId statementId,
                                              IDatabricksClient client,
                                              DatabricksDriverErrorCode internalErrorCode)

Factory method to create a timeout handler for a databricks client with a statement ID. This works with any client that implements `IDatabricksClient`.

Parameters:
  `timeoutSeconds` - Timeout in seconds
  `statementId` - The statement ID
  `client` - The Databricks client
  `internalErrorCode` - Internal driver error code to annotate timeout exceptions
Returns:
  A new TimeoutHandler instance