1<!--$Id: env_class.so,v 10.45 2005/11/30 19:09:47 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: DbEnv</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>DbEnv</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 &lt;db_cxx.h&gt;
23<p>
24class DbEnv {
25public:
26	DbEnv(u_int32 flags);
27	~DbEnv();
28<p>
29	DB_ENV *DbEnv::get_DB_ENV();
30	const DB_ENV *DbEnv::get_const_DB_ENV() const;
31	static DbEnv *DbEnv::get_DbEnv(DB_ENV *dbenv);
32	static const DbEnv *DbEnv::get_const_DbEnv(const DB_ENV *dbenv);
33	...
34};
35</pre></b>
36<hr size=1 noshade>
37<b>Description: DbEnv</b>
38<p>The DbEnv object is the handle for a Berkeley DB environment -- a
39collection including support for some or all of caching, locking,
40logging and transaction subsystems, as well as databases and log files.
41Methods of the DbEnv handle are used to configure the
42environment as well as to operate on subsystems and databases in the
43environment.</p>
44<p>DbEnv handles are free-threaded if the <a href="../api_cxx/env_open.html#DB_THREAD">DB_THREAD</a> flag
45is specified to the <a href="../api_cxx/env_open.html">DbEnv::open</a> method when the environment is opened.
46The DbEnv handle should not be closed while any other handle
47remains open that is using it as a reference (for example, <a href="../api_cxx/db_class.html">Db</a>
48or <a href="../api_cxx/txn_class.html">DbTxn</a>).  Once either the <a href="../api_cxx/env_close.html">DbEnv::close</a> or
49<a href="../api_cxx/env_remove.html">DbEnv::remove</a> methods are called, the handle may not be accessed again,
50regardless of the method's return.</p>
51<p>The constructor creates the DbEnv object.  The constructor
52allocates memory internally; calling the <a href="../api_cxx/env_close.html">DbEnv::close</a> or
53<a href="../api_cxx/env_remove.html">DbEnv::remove</a> methods will free that memory.</p>
54<p>The following <b>flags</b> value may be specified:</p>
55<br>
56<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,
57whenever an error occurs, an exception is thrown that encapsulates the
58error information.  This generally allows for cleaner logic for
59transaction processing because a try block can surround a single
60transaction.  However, if DB_CXX_NO_EXCEPTIONS is specified,
61exceptions are not thrown; instead, each individual function returns an
62error code.</ul>
63<b><a name="DB_RPCCLIENT">DB_RPCCLIENT</a></b><ul compact><li>Create a client environment to connect to a server.</ul>
64<p>The DB_RPCCLIENT flag indicates to the system that this environment
65is remote on a server.  The use of this flag causes the environment
66methods to use functions that call a server instead of local functions.
67Prior to making any environment or database method calls, the application
68must call the <a href="../api_cxx/env_set_rpc_server.html">DbEnv::set_rpc_server</a> function to establish the
69connection to the server.</p>
70<br>
71<p>Each DbEnv object has an associated DB_ENV structure,
72which is used by the underlying implementation of Berkeley DB and its
73C-language API.  The DbEnv::get_DB_ENV method returns a pointer to this
74struct.  Given a const DbEnv object, DbEnv::get_const_DB_ENV
75returns a const pointer to the same struct.</p>
76<p>Given a DB_ENV struct, the DbEnv::get_DbEnv method returns the
77corresponding DbEnv object, if there is one.  If the
78DB_ENV object was not associated with a DbEnv (that is,
79it was not returned from a call to DbEnv::get_DB_ENV), then the result
80of DbEnv::get_DbEnv is undefined.  Given a const DB_ENV struct,
81DbEnv::get_const_Db_Env returns the associated const DbEnv
82object, if there is one.</p>
83<p>These methods may be useful for Berkeley DB applications including  both C
84and C++ language software.  It should not be necessary to use these
85calls in a purely C++ application.</p>
86<hr size=1 noshade>
87<br><b>Class</b>
88DbEnv
89<br><b>See Also</b>
90<a href="../api_cxx/env_list.html">Database Environments and Related Methods</a>
91</tt>
92<table width="100%"><tr><td><br></td><td align=right>
93<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>
94</td></tr></table>
95<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
96</body>
97</html>
98