Sophie

Sophie

distrib > Mandriva > 2007.0 > x86_64 > media > main-release > by-pkgid > a4c98df40e78f6c892308fd6841f950a > files > 1080

lib64db4.2-devel-4.2.52-11mdv2007.0.x86_64.rpm

<!--$Id: dbenv_cxx.so,v 11.10 2000/12/01 17:59:32 bostic Exp $-->
<!--Copyright 1997-2003 by Sleepycat Software, Inc.-->
<!--All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB Reference Guide: Release 3.0: the DbEnv class for C++ and Java</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
</head>
<body bgcolor=white>
<table width="100%"><tr valign=top>
<td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Upgrading Berkeley DB Applications</dl></h3></td>
<td align=right><a href="../upgrade.3.0/value_set.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../upgrade.3.0/db_cxx.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p>
<h3 align=center>Release 3.0: the DbEnv class for C++ and Java</h3>
<p>The DbEnv::appinit() method and two constructors for the DbEnv class are
gone.  There is now a single way to create and initialize the environment.
The way to create an environment is to use the new DbEnv constructor with
one argument.  After this call, the DbEnv can be configured with various
set_XXX methods.  Finally, a call to DbEnv::open is made to initialize
the environment.</p>
<p>Here's a C++ example creating a Berkeley DB environment using the 2.X interface</p>
<blockquote><pre>int dberr;
DbEnv *dbenv = new DbEnv();
<p>
dbenv-&gt;set_error_stream(&cerr);
dbenv-&gt;set_errpfx("myprog");
<p>
if ((dberr = dbenv-&gt;appinit("/database/home",
	NULL, DB_CREATE | DB_INIT_LOCK | DB_INIT_MPOOL)) != 0) {
    cerr &lt;&lt; "failure: " &lt;&lt; strerror(dberr);
    exit (1);
}</pre></blockquote>
<p>In the Berkeley DB 3.0 release, this code would be written as:</p>
<blockquote><pre>int dberr;
DbEnv *dbenv = new DbEnv(0);
<p>
dbenv-&gt;set_error_stream(&cerr);
dbenv-&gt;set_errpfx("myprog");
<p>
if ((dberr = dbenv-&gt;open("/database/home",
	NULL, DB_CREATE | DB_INIT_LOCK | DB_INIT_MPOOL, 0)) != 0) {
    cerr &lt;&lt; "failure: " &lt;&lt; dbenv-&gt;strerror(dberr);
    exit (1);
}</pre></blockquote>
<p>Here's a Java example creating a Berkeley DB environment using the 2.X interface:</p>
<blockquote><pre>int dberr;
DbEnv dbenv = new DbEnv();
<p>
dbenv.set_error_stream(System.err);
dbenv.set_errpfx("myprog");
<p>
dbenv.appinit("/database/home",
    null, Db.DB_CREATE | Db.DB_INIT_LOCK | Db.DB_INIT_MPOOL);</pre></blockquote>
<p>In the Berkeley DB 3.0 release, this code would be written as:</p>
<blockquote><pre>int dberr;
DbEnv dbenv = new DbEnv(0);
<p>
dbenv.set_error_stream(System.err);
dbenv.set_errpfx("myprog");
<p>
dbenv.open("/database/home",
    null, Db.DB_CREATE | Db.DB_INIT_LOCK | Db.DB_INIT_MPOOL, 0);</pre></blockquote>
<p>In the Berkeley DB 2.X release, DbEnv had accessors to obtain "managers" of type
DbTxnMgr, DbMpool, DbLog, DbTxnMgr.  If you used any of these managers,
all their methods are now found directly in the DbEnv class.</p>
<table width="100%"><tr><td><br></td><td align=right><a href="../upgrade.3.0/value_set.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../upgrade.3.0/db_cxx.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p><font size=1><a href="../../sleepycat/legal.html">Copyright (c) 1996-2003</a> <a href="http://www.sleepycat.com">Sleepycat Software, Inc.</a> - All rights reserved.</font>
</body>
</html>