DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

Handling Exceptions

Exception handling was illustrated previously in Implementing the Main Program and Using Transactions exception handling in a Sleepycat Java Collections API application in more detail.

There are two exceptions that must be treated specially: RunRecoveryException and DeadlockException.

RunRecoveryException is thrown when the only solution is to shut down the application and run recovery. All applications must catch this exception and follow the recovery procedure.

When DeadlockException is thrown, the application should normally retry the operation. If a deadlock continues to occur for some maximum number of retries, the application should give up and try again later or take other corrective actions. The Sleepycat Java Collections API provides two APIs for transaction execution.

When using the TransactionRunner class there are two other considerations.

When calling TransactionRunner.run, the unwrapped (nested) exception will be unwrapped and thrown automatically. If you are not using TransactionRunner or if you are handling exceptions directly for some other reason, use the ExceptionUnwrapper.unwrap method to get the nested exception. For example, this can be used to discover that an exception is a RunRecoveryException as shown below.

import com.sleepycat.db.RunRecoveryException;
import com.sleepycat.util.ExceptionUnwrapper;
...
    catch (Exception e)
    {
        e = ExceptionUnwrapper.unwrap(e);
        if (e instanceof RunRecoveryException)
        {
            // follow recovery procedure
        }
    }