DatabasePreemptedException (Oracle - Berkeley DB Java Edition API)
Date: 2014-12-16

com.sleepycat.je.rep

## Class DatabasePreemptedException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - java.lang.RuntimeException
      - - com.sleepycat.je.DatabaseException
        - - com.sleepycat.je.OperationFailureException
          - - com.sleepycat.je.rep.DatabasePreemptedException

- All Implemented Interfaces:
    Serializable

      public class DatabasePreemptedException
      extends OperationFailureException

  Thrown when attempting to use a Database handle that was forcibly closed by replication. This exception only occurs in a replicated environment and normally only occurs on a Replica node. In the case of a DPL schema upgrade where an entity class or secondary key is renamed, it may also occur on a Master node, as described below.

  This exception occurs when accessing a database or store and one of the following methods was recently executed on the master node and then replayed on a replica node: `truncateDatabase`, `removeDatabase` and `renameDatabase`.

  When using the `DPL`, this occurs only in two circumstances:

  1. This exception is thrown on a Replica node when the `truncateClass` method has been called on the Master node.
  2. This exception is thrown on a Replica or Master node when an entity class or secondary key has been renamed and the application has been upgraded. See Upgrading a Replication Group.

  When this exception occurs, the application must close any open cursors and abort any open transactions that are using the database or store, and then close the database or store handle. If the application wishes, it may then reopen the database (if it still exists) or store.

  Some applications may wish to coordinate the Master and Replica sites to prevent a Replica from accessing a database that is being truncated, removed or renamed, and thereby prevent this exception. Such coordination is not directly supported by JE. The DatabasePreemptedException is provided to allow an application to handle database truncation, removal and renaming without such coordination between nodes.

  The `Transaction` handle is not invalidated as a result of this exception.

  Since:
    4.0
  See Also:
    Serialized Form

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Database` | `getDatabase()` Returns the database handle that was forcibly closed.
    `String` | `getDatabaseName()` Returns the name of the database that was forcibly closed.

    - ### Methods inherited from class com.sleepycat.je.DatabaseException

      `getMessage`

    - ### Methods inherited from class java.lang.Throwable

      `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

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

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

- - ### Method Detail

    - #### getDatabase

          public Database getDatabase()

      Returns the database handle that was forcibly closed.

    - #### getDatabaseName

          public String getDatabaseName()

      Returns the name of the database that was forcibly closed.

Copyright (c) 2004, 2014 Oracle and/or its affiliates. All rights reserved.