# 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
Constructor
Description
`TimeoutHandler(int timeoutSeconds, String operationDescription, Runnable onTimeoutAction)`
Creates a new timeout handler with the provided parameters.

## Method Summary

Modifier and Type
Method
Description
`void`
`checkTimeout()`
Checks if the operation has timed out.
`static TimeoutHandler`
`forStatement(int timeoutSeconds, StatementId statementId, IDatabricksClient client)`
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 Details

### TimeoutHandler

public TimeoutHandler(int timeoutSeconds, String operationDescription, Runnable onTimeoutAction)
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

## Method Details

### 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)
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
Returns:
  A new TimeoutHandler instance