<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Closing Database Environments</title>
<link rel="stylesheet" href="gettingStarted.css" type="text/css" />
<meta name="generator" content="DocBook XSL Stylesheets V1.62.4" />
<link rel="home" href="index.html" title="Getting Started with Berkeley DB" />
<link rel="up" href="Env.html" title="Chapter 2. Database Environments" />
<link rel="previous" href="Env.html" title="Chapter 2. Database Environments" />
<link rel="next" href="EnvProps.html" title="Environment Properties" />
</head>
<body>
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">Closing Database Environments</th>
</tr>
<tr>
<td width="20%" align="left"><a accesskey="p" href="Env.html">Prev</a> </td>
<th width="60%" align="center">Chapter 2. Database Environments</th>
<td width="20%" align="right"> <a accesskey="n" href="EnvProps.html">Next</a></td>
</tr>
</table>
<hr />
</div>
<div class="sect1" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both"><a id="EnvClose"></a>Closing Database Environments</h2>
</div>
</div>
<div></div>
</div>
<p>
You close your environment by calling the
<tt class="methodname">Environment.close()</tt>
method. This method performs a checkpoint, so it is not necessary to perform a sync or a checkpoint explicitly
before calling it. For information on checkpoints, see the
<i class="citetitle">Berkeley DB Java Edition Getting Started with Transaction Processing</i> guide.
For information on syncs, see
<span>
the <i class="citetitle">Getting Started with Transaction Processing for Java</i> guide.
</span>
</p>
<pre class="programlisting">import com.sleepycat.db.DatabaseException;
import com.sleepycat.db.Environment;
...
try {
if (myDbEnvironment != null) {
myDbEnvironment.close();
}
} catch (DatabaseException dbe) {
// Exception handling goes here
} </pre>
<p>You should close your environment(s) only after all other
database activities have completed and you have closed any databases
currently opened in the environment.</p>
<p>
Closing the last environment handle in your application causes all
internal data structures to be
<span>
released.
</span>
If there are any opened databases or stores,
then DB will complain before closing them as well.
At this time, any open cursors are also closed, and any on-going transactions are aborted.
</p>
</div>
<div class="navfooter">
<hr />
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"><a accesskey="p" href="Env.html">Prev</a> </td>
<td width="20%" align="center">
<a accesskey="u" href="Env.html">Up</a>
</td>
<td width="40%" align="right"> <a accesskey="n" href="EnvProps.html">Next</a></td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Chapter 2. Database Environments </td>
<td width="20%" align="center">
<a accesskey="h" href="index.html">Home</a>
</td>
<td width="40%" align="right" valign="top"> Environment Properties</td>
</tr>
</table>
</div>
</body>
</html>
Copyright 2K16 - 2K18 Indonesian Hacker Rulez