2
<!--Copyright 1997-2002 by Sleepycat Software, Inc.-->
3
<!--All rights reserved.-->
4
<!--See the file LICENSE for redistribution information.-->
7
<title>Berkeley DB: Db</title>
8
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
9
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
12
<a name="2"><!--meow--></a>
13
<table width="100%"><tr valign=top>
18
<a href="../api_cxx/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
23
#include <db_cxx.h>
27
Db(DbEnv *dbenv, u_int32_t flags);
31
const DB *Db::get_const_DB() const;
32
static Db *Db::get_Db(DB *db);
33
static const Db *Db::get_const_Db(const DB *db);
38
<p>The Db handle is the handle for a Berkeley DB database, which may or
39
may not be part of a database environment. Db handles are
40
free-threaded if the <a href="../api_cxx/env_open.html#DB_THREAD">DB_THREAD</a> flag is specified to the
41
<a href="../api_cxx/db_open.html">Db::open</a> method when the database is opened or if the database
42
environment in which the database is opened is free-threaded. The
43
handle should not be closed while any other handle that refers to the
44
database is in use; for example, database handles must not be closed
45
while cursor handles into the database remain open, or transactions that
46
include operations on the database have not yet been committed or
47
aborted. Once the <a href="../api_cxx/db_close.html">Db::close</a>, <a href="../api_cxx/db_remove.html">Db::remove</a>, or
48
<a href="../api_cxx/db_rename.html">Db::rename</a> methods are called, the handle may not be accessed again,
49
regardless of the method's return.
50
<p>The constructor creates a Db object that is the handle for a
51
Berkeley DB database. The constructor allocates memory internally; calling
52
the <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
54
<p>If no <b>dbenv</b> value is specified, the database is standalone; that
55
is, it is not part of any Berkeley DB environment.
56
<p>If a <b>dbenv</b> value is specified, the database is created within
57
the specified Berkeley DB environment. The database access methods
58
automatically make calls to the other subsystems in Berkeley DB based on the
59
enclosing environment. For example, if the environment has been
60
configured to use locking, the access methods will automatically acquire
61
the correct locks when reading and writing pages of the database.
62
<p>The <b>flags</b> value must be set to 0 or by bitwise inclusively <b>OR</b>'ing together one or
63
more of the following values:
65
<p><dt><a name="DB_CXX_NO_EXCEPTIONS">DB_CXX_NO_EXCEPTIONS</a><dd>The Berkeley DB C++ API supports two different error behaviors. By default,
66
whenever an error occurs, an exception is thrown that encapsulates the
67
error information. This generally allows for cleaner logic for
68
transaction processing because a try block can surround a single
69
transaction. However, if DB_CXX_NO_EXCEPTIONS is specified,
70
exceptions are not thrown; instead, each individual function returns an
72
<p>If <b>dbenv</b> is not null, this flag is ignored, and the error behavior
73
of the specified environment is used instead.
74
<p><dt><a name="DB_XA_CREATE">DB_XA_CREATE</a><dd>Instead of creating a standalone database, create a database intended to
75
be accessed via applications running under a X/Open conformant Transaction
76
Manager. The database will be opened in the environment specified by the
77
OPENINFO parameter of the GROUPS section of the ubbconfig file. See the
78
<a href="../ref/xa/intro.html">XA Resource Manager</a> chapter in the
79
Reference Guide for more information.
81
<p>Each Db object has an associated DB struct, which is
82
used by the underlying implementation of Berkeley DB and its C-language API.
83
The Db::get_DB method returns a pointer to this struct. Given a const
84
Db object, Db::get_const_DB returns a const pointer to the
86
<p>Given a DB struct, the Db::get_Db method returns the
87
corresponding Db object, if there is one. If the DB
88
object was not associated with a Db (that is, it was not
89
returned from a call to Db::get_DB), then the result of Db::get_Db is
90
undefined. Given a const DB struct, Db::get_const_Db returns
91
the associated const Db object, if there is one.
92
<p>These methods may be useful for Berkeley DB applications including both C
93
and C++ language software. It should not be necessary to use these
94
calls in a purely C++ application.
98
<a href="../api_cxx/db_list.html">Databases and Related Methods</a>
100
<table width="100%"><tr><td><br></td><td align=right>
101
<a href="../api_cxx/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
103
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>