# DbEnv.txn_recover

`

###

    import com.sleepycat.db.*;

    public DbPreplist[] txn_recover(int count, int flags)
        throws DbException;

# Description

The DbEnv.txn_recover interface returns a list of prepared but not yet resolved transactions. The DbEnv.txn_recover method should only be called after the environment has been recovered. Because database environment state must be preserved between recovery and the application calling DbEnv.txn_recover, applications must either call DbEnv.txn_recover using the same environment handle used when recovery is done, or the database environment must not be configured using the Db.DB_PRIVATE flag.

The DbEnv.txn_recover method returns a list of transactions that must be resolved by the application (committed, aborted or discarded). The return value is an array of objects of type DbPreplist; the following DbPreplist fields will be filled in:

public DbTxn txn;
  The transaction handle for the transaction.

public byte[] gid;
  The global transaction ID for the transaction. The global transaction ID is the one specified when the transaction was prepared. The application is responsible for ensuring uniqueness among global transaction IDs.

The application must call DbTxn.abort, DbTxn.commit or DbTxn.discard on each returned DbTxn handle before starting any new operations.

The count parameter specifies the number of maximum size of the array that should be returned.

The flags value must be set to one of the following values:

Db.DB_FIRST
  Begin returning a list of prepared, but not yet resolved transactions.

Db.DB_NEXT
  Continue returning a list of prepared, but not yet resolved transactions, starting where the last call to DbEnv.txn_recover left off.

The DbEnv.txn_recover method throws an exception that encapsulates a non-zero error value on failure.

# Errors

The DbEnv.txn_recover method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods. If a catastrophic error has occurred, the DbEnv.txn_recover method may fail and throw a DbRunRecoveryException, in which case all subsequent Berkeley DB calls will fail in the same way.

# Class

DbEnv, DbTxn

# See Also

DbEnv.set_tx_max, DbEnv.set_tx_timestamp, DbTxn.abort, DbEnv.txn_begin, DbEnv.txn_checkpoint, DbTxn.commit, DbTxn.discard, DbTxn.id, DbTxn.prepare, DbEnv.txn_recover, DbTxn.set_timeout and DbEnv.txn_stat.`

Copyright Sleepycat Software