Skip Headers

# Exception Handlers

Previous

Next

Exception handlers allow any exception that occurs in a session to be caught and processed. Exception handlers can be used for debugging purposes, or to resolve database timeouts or failures.

To use exception handlers, register an implementor of the `oracle.toplink.exceptions.ExceptionHandler` interface with the session (see "Configuring an Exception Handler").

If an exception occurs during a session operation, such as executing a query, the exception is passed to the exception handler. The exception handler can either rethrow the exception, or handle the exception and retry the operation. When handling exceptions, ensure that the following conditions are met:

- If you are performing a write query and you are within a transaction, you should not retry the operation.

- If you are performing a read query, you may retry the operation, and, if successful, return the query result.

If your exception handler cannot proceed, you should throw an appropriate application-specific exception.

For more information on the types of exceptions that TopLink can throw, see Troubleshooting a TopLink Application.