1<!--$Id: db_class.so,v 10.53 2007/10/26 14:52:37 bostic Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB: Db</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<table width="100%"><tr valign=top> 12<td> 13<b>Db</b> 14</td> 15<td align=right> 16<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a> 17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td> 18</tr></table> 19<hr size=1 noshade> 20<tt> 21<b><pre> 22#include <db_cxx.h> 23<p> 24class Db { 25public: 26 Db(DbEnv *dbenv, u_int32_t flags); 27 ~Db(); 28<p> 29 DB *Db::get_DB(); 30 const DB *Db::get_const_DB() const; 31 static Db *Db::get_Db(DB *db); 32 static const Db *Db::get_const_Db(const DB *db); 33 ... 34}; 35</pre></b> 36<hr size=1 noshade> 37<b>Description: Db</b> 38<p>The Db handle is the handle for a Berkeley DB database, which may or 39may not be part of a database environment.</p> 40<p>Db handles are free-threaded if the <a href="../api_cxx/env_open.html#DB_THREAD">DB_THREAD</a> flag is 41specified to the <a href="../api_cxx/db_open.html">Db::open</a> method when the database is opened or if the 42database environment in which the database is opened is free-threaded. 43The handle should not be closed while any other handle that refers to 44the database is in use; for example, database handles must not be closed 45while cursor handles into the database remain open, or transactions that 46include operations on the database have not yet been committed or 47aborted. Once the <a href="../api_cxx/db_close.html">Db::close</a>, <a href="../api_cxx/db_remove.html">Db::remove</a>, 48<a href="../api_cxx/db_rename.html">Db::rename</a>, or <a href="../api_cxx/db_verify.html">Db::verify</a> methods are called, the handle may 49not be accessed again, regardless of the method's return.</p> 50<p>The constructor creates a Db object that is the handle for a 51Berkeley DB database. The constructor allocates memory internally; calling 52the <a href="../api_cxx/db_close.html">Db::close</a>, <a href="../api_cxx/db_remove.html">Db::remove</a> or <a href="../api_cxx/db_rename.html">Db::rename</a> methods will 53free that memory.</p> 54<p>Each Db object has an associated DB struct, which is 55used by the underlying implementation of Berkeley DB and its C-language API. 56The Db::get_DB method returns a pointer to this struct. Given a const 57Db object, Db::get_const_DB returns a const pointer to the 58same struct.</p> 59<p>Given a DB struct, the Db::get_Db method returns the 60corresponding Db object, if there is one. If the DB 61object was not associated with a Db (that is, it was not 62returned from a call to Db::get_DB), then the result of Db::get_Db is 63undefined. Given a const DB struct, Db::get_const_Db returns 64the associated const Db object, if there is one.</p> 65<p>These methods may be useful for Berkeley DB applications including both C 66and C++ language software. It should not be necessary to use these 67calls in a purely C++ application.</p> 68<b>Parameters</b> <br> 69 <b>dbenv</b><ul compact><li>If no <b>dbenv</b> value is specified, the database is standalone; that 70is, it is not part of any Berkeley DB environment. 71<p>If a <b>dbenv</b> value is specified, the database is created within 72the specified Berkeley DB environment. The database access methods 73automatically make calls to the other subsystems in Berkeley DB based on the 74enclosing environment. For example, if the environment has been 75configured to use locking, the access methods will automatically acquire 76the correct locks when reading and writing pages of the database.</p></ul> 77 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or by bitwise inclusively <b>OR</b>'ing together one 78or more of the following values: 79<br> 80<b><a name="DB_CXX_NO_EXCEPTIONS">DB_CXX_NO_EXCEPTIONS</a></b><ul compact><li>The Berkeley DB C++ API supports two different error behaviors. By default, 81whenever an error occurs, an exception is thrown that encapsulates the 82error information. This generally allows for cleaner logic for 83transaction processing because a try block can surround a single 84transaction. However, if DB_CXX_NO_EXCEPTIONS is specified, 85exceptions are not thrown; instead, each individual function returns an 86error code. 87<p>If <b>dbenv</b> is not null, this flag is ignored, and the error behavior 88of the specified environment is used instead.</p></ul> 89<b><a name="DB_XA_CREATE">DB_XA_CREATE</a></b><ul compact><li>Instead of creating a standalone database, create a database intended 90to be accessed via applications running under an X/Open conformant 91Transaction Manager. The database will be opened in the environment 92specified by the OPENINFO parameter of the GROUPS section of the 93ubbconfig file. See the <a href="../ref/xa/xa_intro.html">XA 94Introduction</a> section in the Berkeley DB Reference Guide for more information.</ul> 95<br></ul> 96<br> 97<hr size=1 noshade> 98<br><b>Class</b> 99Db 100<br><b>See Also</b> 101<a href="../api_cxx/db_list.html">Databases and Related Methods</a> 102</tt> 103<table width="100%"><tr><td><br></td><td align=right> 104<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a> 105</td></tr></table> 106<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 107</body> 108</html> 109