1
<!--$Id: txn_prepare.so,v 10.22 2001/05/03 14:22:06 bostic Exp $-->
2
<!--Copyright 1997-2001 by Sleepycat Software, Inc.-->
3
<!--All rights reserved.-->
6
<title>Berkeley DB: DbTxn.prepare</title>
7
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
8
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
11
<a name="2"><!--meow--></a>
12
<table width="100%"><tr valign=top>
14
<h1>DbTxn.prepare</h1>
17
<a href="../api_java/java_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
22
import com.sleepycat.db.*;
24
public void prepare(byte[] gid)
28
<a name="3"><!--meow--></a>
29
<p>The DbTxn.prepare method initiates the beginning of a two-phase commit.
30
<p>In a distributed transaction environment, Berkeley DB can be used as a local
31
transaction manager. In this case, the distributed transaction manager
32
must send <i>prepare</i> messages to each local manager. The local
33
manager must then issue a DbTxn.prepare and await its successful
34
return before responding to the distributed transaction manager. Only
35
after the distributed transaction manager receives successful responses
36
from all of its <i>prepare</i> messages should it issue any
37
<i>commit</i> messages.
38
<p>In the case of nested transactions, preparing the parent
39
causes all unresolved children of the parent transaction to be committed.
40
Child transactions should never be explicitly prepared.
41
Their fate will be resolved along with their parent's during
43
<p>The <b>gid</b> parameter specifies the global transaction ID by which this
44
transaction will be known. This global transaction ID will be returned
45
in calls to <a href="../api_java/txn_recover.html">DbEnv.txn_recover</a>, telling the application which global
46
transactions must be resolved.
47
The <b>gid</b> parameter must be sized at least Db.DB_XIDDATASIZE
48
(currently 128) bytes; only the first Db.DB_XIDDATASIZE bytes
50
<p>The DbTxn.prepare method throws an exception that encapsulates a non-zero error value on
53
<p>The DbTxn.prepare method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods.
54
If a catastrophic error has occurred, the DbTxn.prepare method may fail and throw
55
a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, in which case all subsequent Berkeley DB calls
56
will fail in the same way.
58
<a href="../api_java/dbenv_class.html">DbEnv</a>, <a href="../api_java/txn_class.html">DbTxn</a>
60
<a href="../api_java/env_set_tx_max.html">DbEnv.set_tx_max</a>,
61
<a href="../api_java/env_set_tx_timestamp.html">DbEnv.set_tx_timestamp</a>,
62
<a href="../api_java/txn_abort.html">DbTxn.abort</a>,
63
<a href="../api_java/txn_begin.html">DbEnv.txn_begin</a>,
64
<a href="../api_java/txn_checkpoint.html">DbEnv.txn_checkpoint</a>,
65
<a href="../api_java/txn_commit.html">DbTxn.commit</a>,
66
<a href="../api_java/txn_discard.html">DbTxn.discard</a>,
67
<a href="../api_java/txn_id.html">DbTxn.id</a>,
68
<a href="../api_java/txn_prepare.html">DbTxn.prepare</a>,
69
<a href="../api_java/txn_recover.html">DbEnv.txn_recover</a>,
71
<a href="../api_java/txn_stat.html">DbEnv.txn_stat</a>.
73
<table width="100%"><tr><td><br></td><td align=right>
74
<a href="../api_java/java_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
76
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>