Berkeley DB: DbTxn
Description: Berkeley DB: An embedded database programmatic toolkit.
Keywords: embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++

### DbTxn |

`

###

    #include <db_cxx.h>

    class DbTxn {
    public:
    	DB_TXN *DbTxn::get_DB_TXN();
    	const DB_TXN *DbTxn::get_const_DB_TXN() const;
    	static DbTxn *DbTxn::get_DbTxn(DB_TXN *txn);
    	static const DbTxn *DbTxn::get_const_DbTxn(const DB_TXN *txn);
    	...
    };

### Description: DbTxn

The DbTxn object is the handle for a transaction. Methods of the DbTxn handle are used to configure, abort and commit the transaction. DbTxn handles are provided to Db methods in order to transactionally protect those database operations.

DbTxn handles are not free-threaded; transactions handles may be used by multiple threads, but only serially, that is, the application must serialize access to the DbTxn handle. Once the DbTxn::abort or DbTxn::commit methods are called, the handle may not be accessed again, regardless of the method's return. In addition, parent transactions may not issue any Berkeley DB operations while they have active child transactions (child transactions that have not yet been committed or aborted) except for DbEnv::txn_begin, DbTxn::abort and DbTxn::commit.

Each DbTxn object has an associated DB_TXN struct, which is used by the underlying implementation of Berkeley DB and its C-language API. The DbTxn::get_DB_TXN method returns a pointer to this struct. Given a const DbTxn object, DbTxn::get_const_DB_TXN returns a const pointer to the same struct.

Given a DB_TXN struct, the Db::get_DbTxn method returns the corresponding DbTxn object, if there is one. If the DB_TXN object was not associated with a DbTxn (that is, it was not returned from a call to DbTxn::get_DB_TXN), then the result of DbTxn::get_DbTxn is undefined. Given a const DB_TXN struct, DbTxn::get_const_DbTxn returns the associated const DbTxn object, if there is one.

These methods may be useful for Berkeley DB applications including both C and C++ language software. It should not be necessary to use these calls in a purely C++ application.

### Class

DbEnv, DbTxn

### See Also

Transaction Subsystem and Related Methods`

Copyright (c) 1996,2007 Oracle. All rights reserved.