<!--$Id: apis.so,v 10.29 2003/10/18 19:15:57 bostic Exp $-->
<!--Copyright (c) 1997,2008 Oracle. All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB Reference Guide: Programmatic APIs</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
</head>
<body bgcolor=white>
<a name="2"><!--meow--></a>
<table width="100%"><tr valign=top>
<td><b><dl><dt>Berkeley DB Reference Guide:<dd>Architecture</dl></b></td>
<td align=right><a href="../arch/progmodel.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../arch/script.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p align=center><b>Programmatic APIs</b></p>
<p>The Berkeley DB subsystems can be accessed through interfaces from multiple
languages. Applications can use Berkeley DB via C, C++ or Java, as well as a
variety of scripting languages such as Perl, Python, Ruby or Tcl.
Environments can be shared among applications written by using any of
these interfaces. For example, you might have a local server written
in C or C++, a script for an administrator written in Perl or Tcl, and
a Web-based user interface written in Java -- all sharing a single
database environment.</p>
<b>C</b>
<p>The Berkeley DB library is written entirely in ANSI C. C applications use a
single include file:</p>
<blockquote><pre>#include <db.h></pre></blockquote>
<b>C++</b>
<p>The C++ classes provide a thin wrapper around the C API, with the major
advantages being improved encapsulation and an optional exception
mechanism for errors. C++ applications use a single include file:</p>
<blockquote><pre>#include <db_cxx.h></pre></blockquote>
<p>The classes and methods are named in a fashion that directly corresponds
to structures and functions in the C interface. Likewise, arguments to
methods appear in the same order as the C interface, except to remove the
explicit <b>this</b> pointer. The #defines used for flags are identical
between the C and C++ interfaces.</p>
<p>As a rule, each C++ object has exactly one structure from the underlying
C API associated with it. The C structure is allocated with each
constructor call and deallocated with each destructor call. Thus, the
rules the user needs to follow in allocating and deallocating structures
are the same between the C and C++ interfaces.</p>
<p>To ensure portability to many platforms, both new and old, Berkeley DB makes
as few assumptions as possible about the C++ compiler and library. For
example, it does not expect STL, templates, or namespaces to be
available. The newest C++ feature used is exceptions, which are used
liberally to transmit error information. Even the use of exceptions
can be disabled at runtime.</p>
<b>Java</b>
<p>The Java classes provide a layer around the C API that is almost identical
to the C++ layer. The classes and methods are, for the most part
identical to the C++ layer. Berkeley DB constants and #defines are represented as
"static final int" values. Error conditions are communicated as Java
exceptions.</p>
<p>As in C++, each Java object has exactly one structure from the underlying
C API associated with it. The Java structure is allocated with each
constructor or open call, but is deallocated only by the Java garbage
collector. Because the timing of garbage collection is not predictable,
applications should take care to do a close when finished with any object
that has a close method.</p>
<b>Dbm/Ndbm, Hsearch</b>
<p>Berkeley DB supports the standard UNIX <a href="../../api_c/dbm.html">dbm</a>, <a href="../../api_c/dbm.html">ndbm</a>, and
<a href="../../api_c/hsearch.html">hsearch</a> interfaces. After including a new header file and
recompiling, programs will run orders of magnitude faster, and
underlying databases can grow as large as necessary. Also, historic
<a href="../../api_c/dbm.html">dbm</a> and <a href="../../api_c/dbm.html">ndbm</a> applications can fail once some number of
entries are inserted into the database, in which the number depends on
the effectiveness of the internal hashing function on the particular
data set. This is not a problem with Berkeley DB.</p>
<table width="100%"><tr><td><br></td><td align=right><a href="../arch/progmodel.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../arch/script.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font>
</body>
</html>
Copyright 2K16 - 2K18 Indonesian Hacker Rulez