1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<!--NewPage--> 3<HTML> 4<HEAD> 5<!-- Generated by javadoc (build 1.6.0_03) on Mon Apr 12 16:25:48 EDT 2010 --> 6<TITLE> 7Transaction (Oracle - Berkeley DB Java API) 8</TITLE> 9 10<META NAME="date" CONTENT="2010-04-12"> 11 12<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../style.css" TITLE="Style"> 13 14<SCRIPT type="text/javascript"> 15function windowTitle() 16{ 17 if (location.href.indexOf('is-external=true') == -1) { 18 parent.document.title="Transaction (Oracle - Berkeley DB Java API)"; 19 } 20} 21</SCRIPT> 22<NOSCRIPT> 23</NOSCRIPT> 24 25</HEAD> 26 27<BODY BGCOLOR="white" onload="windowTitle();"> 28<HR> 29 30 31<!-- ========= START OF TOP NAVBAR ======= --> 32<A NAME="navbar_top"><!-- --></A> 33<A HREF="#skip-navbar_top" title="Skip navigation links"></A> 34<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> 35<TR> 36<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> 37<A NAME="navbar_top_firstrow"><!-- --></A> 38<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> 39 <TR ALIGN="center" VALIGN="top"> 40 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> 41 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> 42 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 43 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Transaction.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> 44 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 45 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 46 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 47 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> 48 </TR> 49</TABLE> 50</TD> 51<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> 52<b>Berkeley DB</b><br><font size="-1"> version 4.8.30</font></EM> 53</TD> 54</TR> 55 56<TR> 57<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 58 <A HREF="../../../com/sleepycat/db/StatsConfig.html" title="class in com.sleepycat.db"><B>PREV CLASS</B></A> 59 <A HREF="../../../com/sleepycat/db/TransactionConfig.html" title="class in com.sleepycat.db"><B>NEXT CLASS</B></A></FONT></TD> 60<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 61 <A HREF="../../../index.html?com/sleepycat/db/Transaction.html" target="_top"><B>FRAMES</B></A> 62 <A HREF="Transaction.html" target="_top"><B>NO FRAMES</B></A> 63 <SCRIPT type="text/javascript"> 64 <!-- 65 if(window==top) { 66 document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); 67 } 68 //--> 69</SCRIPT> 70<NOSCRIPT> 71 <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A> 72</NOSCRIPT> 73 74 75</FONT></TD> 76</TR> 77<TR> 78<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 79 SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> 80<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 81DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> 82</TR> 83</TABLE> 84<A NAME="skip-navbar_top"></A> 85<!-- ========= END OF TOP NAVBAR ========= --> 86 87<HR> 88<!-- ======== START OF CLASS DATA ======== --> 89<H2> 90<FONT SIZE="-1"> 91com.sleepycat.db</FONT> 92<BR> 93Class Transaction</H2> 94<PRE> 95<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</A> 96 <IMG SRC="../../../resources/inherit.gif" ALT="extended by "><B>com.sleepycat.db.Transaction</B> 97</PRE> 98<HR> 99<DL> 100<DT><PRE>public class <B>Transaction</B><DT>extends <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></DL> 101</PRE> 102 103<P> 104The Transaction object is the handle for a transaction. Methods off the 105transaction handle are used to configure, abort and commit the 106transaction. Transaction handles are provided to other Berkeley DB 107methods in order to transactionally protect those operations. 108<p> 109Transaction handles are not free-threaded; transactions handles may 110be used by multiple threads, but only serially, that is, the application 111must serialize access to the handle. Once the 112<A HREF="../../../com/sleepycat/db/Transaction.html#abort()"><CODE>Transaction.abort</CODE></A>, <A HREF="../../../com/sleepycat/db/Transaction.html#commit()"><CODE>Transaction.commit</CODE></A> or 113<A HREF="../../../com/sleepycat/db/Transaction.html#discard()"><CODE>Transaction.discard</CODE></A> 114methods are called, the handle may 115not be accessed again, regardless of the success or failure of the method. 116In addition, parent transactions may not issue any Berkeley DB operations 117while they have active child transactions (child transactions that have 118not yet been committed or aborted) except for <A HREF="../../../com/sleepycat/db/Environment.html#beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)"><CODE>Environment.beginTransaction</CODE></A>, <A HREF="../../../com/sleepycat/db/Transaction.html#abort()"><CODE>Transaction.abort</CODE></A> and <A HREF="../../../com/sleepycat/db/Transaction.html#commit()"><CODE>Transaction.commit</CODE></A>. 119<p> 120To obtain a transaction with default attributes: 121<blockquote><pre> 122 Transaction txn = myEnvironment.beginTransaction(null, null); 123</pre></blockquote> 124To customize the attributes of a transaction: 125<blockquote><pre> 126 TransactionConfig config = new TransactionConfig(); 127 config.setDirtyRead(true); 128 Transaction txn = myEnvironment.beginTransaction(null, config); 129</pre></blockquote> 130<P> 131 132<P> 133<HR> 134 135<P> 136 137<!-- ========== METHOD SUMMARY =========== --> 138 139<A NAME="method_summary"><!-- --></A> 140<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 141<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 142<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> 143<B>Method Summary</B></FONT></TH> 144</TR> 145<TR BGCOLOR="white" CLASS="TableRowColor"> 146<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 147<CODE> void</CODE></FONT></TD> 148<TD><CODE><B><A HREF="../../../com/sleepycat/db/Transaction.html#abort()">abort</A></B>()</CODE> 149 150<BR> 151 Cause an abnormal termination of the transaction.</TD> 152</TR> 153<TR BGCOLOR="white" CLASS="TableRowColor"> 154<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 155<CODE> void</CODE></FONT></TD> 156<TD><CODE><B><A HREF="../../../com/sleepycat/db/Transaction.html#commit()">commit</A></B>()</CODE> 157 158<BR> 159 End the transaction.</TD> 160</TR> 161<TR BGCOLOR="white" CLASS="TableRowColor"> 162<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 163<CODE> void</CODE></FONT></TD> 164<TD><CODE><B><A HREF="../../../com/sleepycat/db/Transaction.html#commitNoSync()">commitNoSync</A></B>()</CODE> 165 166<BR> 167 End the transaction, not committing synchronously.</TD> 168</TR> 169<TR BGCOLOR="white" CLASS="TableRowColor"> 170<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 171<CODE> void</CODE></FONT></TD> 172<TD><CODE><B><A HREF="../../../com/sleepycat/db/Transaction.html#commitSync()">commitSync</A></B>()</CODE> 173 174<BR> 175 End the transaction, committing synchronously.</TD> 176</TR> 177<TR BGCOLOR="white" CLASS="TableRowColor"> 178<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 179<CODE> void</CODE></FONT></TD> 180<TD><CODE><B><A HREF="../../../com/sleepycat/db/Transaction.html#commitWriteNoSync()">commitWriteNoSync</A></B>()</CODE> 181 182<BR> 183 End the transaction, writing but not flushing the log.</TD> 184</TR> 185<TR BGCOLOR="white" CLASS="TableRowColor"> 186<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 187<CODE> void</CODE></FONT></TD> 188<TD><CODE><B><A HREF="../../../com/sleepycat/db/Transaction.html#discard()">discard</A></B>()</CODE> 189 190<BR> 191 Free up all the per-process resources associated with the specified 192 <A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db"><CODE>Transaction</CODE></A> handle, neither committing nor aborting the 193 transaction.</TD> 194</TR> 195<TR BGCOLOR="white" CLASS="TableRowColor"> 196<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 197<CODE> int</CODE></FONT></TD> 198<TD><CODE><B><A HREF="../../../com/sleepycat/db/Transaction.html#getId()">getId</A></B>()</CODE> 199 200<BR> 201 Return the transaction's unique ID.</TD> 202</TR> 203<TR BGCOLOR="white" CLASS="TableRowColor"> 204<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 205<CODE> <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A></CODE></FONT></TD> 206<TD><CODE><B><A HREF="../../../com/sleepycat/db/Transaction.html#getName()">getName</A></B>()</CODE> 207 208<BR> 209 Get the user visible name for the transaction.</TD> 210</TR> 211<TR BGCOLOR="white" CLASS="TableRowColor"> 212<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 213<CODE> void</CODE></FONT></TD> 214<TD><CODE><B><A HREF="../../../com/sleepycat/db/Transaction.html#prepare(byte[])">prepare</A></B>(byte[] gid)</CODE> 215 216<BR> 217 Initiate the beginning of a two-phase commit.</TD> 218</TR> 219<TR BGCOLOR="white" CLASS="TableRowColor"> 220<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 221<CODE> void</CODE></FONT></TD> 222<TD><CODE><B><A HREF="../../../com/sleepycat/db/Transaction.html#setLockTimeout(long)">setLockTimeout</A></B>(long timeOut)</CODE> 223 224<BR> 225 Configure the lock request timeout value for the transaction.</TD> 226</TR> 227<TR BGCOLOR="white" CLASS="TableRowColor"> 228<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 229<CODE> void</CODE></FONT></TD> 230<TD><CODE><B><A HREF="../../../com/sleepycat/db/Transaction.html#setName(java.lang.String)">setName</A></B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> name)</CODE> 231 232<BR> 233 Set the user visible name for the transaction.</TD> 234</TR> 235<TR BGCOLOR="white" CLASS="TableRowColor"> 236<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 237<CODE> void</CODE></FONT></TD> 238<TD><CODE><B><A HREF="../../../com/sleepycat/db/Transaction.html#setTxnTimeout(long)">setTxnTimeout</A></B>(long timeOut)</CODE> 239 240<BR> 241 Configure the timeout value for the transaction lifetime.</TD> 242</TR> 243</TABLE> 244 <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> 245<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 246<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> 247<TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></B></TH> 248</TR> 249<TR BGCOLOR="white" CLASS="TableRowColor"> 250<TD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD> 251</TR> 252</TABLE> 253 254<P> 255 256<!-- ============ METHOD DETAIL ========== --> 257 258<A NAME="method_detail"><!-- --></A> 259<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 260<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 261<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> 262<B>Method Detail</B></FONT></TH> 263</TR> 264</TABLE> 265 266<A NAME="abort()"><!-- --></A><H3> 267abort</H3> 268<PRE> 269public void <B>abort</B>() 270 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE> 271<DL> 272<DD>Cause an abnormal termination of the transaction. 273 <p> 274 The log is played backward, and any necessary undo operations are done. 275 Before Transaction.abort returns, any locks held by the transaction will 276 have been released. 277 <p> 278 In the case of nested transactions, aborting a parent transaction 279 causes all children (unresolved or not) of the parent transaction 280 to be aborted. 281 <p> 282 All cursors opened within the transaction must be closed before the 283 transaction is aborted. 284 <p> 285 After Transaction.abort has been called, regardless of its return, the 286 <A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db"><CODE>Transaction</CODE></A> handle may not be accessed again. 287 <p> 288 <p> 289<P> 290<DD><DL> 291 292<DT><B>Throws:</B> 293<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - if a failure occurs.</DL> 294</DD> 295</DL> 296<HR> 297 298<A NAME="commit()"><!-- --></A><H3> 299commit</H3> 300<PRE> 301public void <B>commit</B>() 302 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE> 303<DL> 304<DD>End the transaction. If the environment is configured for synchronous 305commit, the transaction will be committed synchronously to stable 306storage before the call returns. This means the transaction will exhibit 307all of the ACID (atomicity, consistency, isolation, and durability) 308properties. 309<p> 310If the environment is not configured for synchronous commit, the commit 311will not necessarily have been committed to stable storage before the 312call returns. This means the transaction will exhibit the ACI (atomicity, 313consistency, and isolation) properties, but not D (durability); that is, 314database integrity will be maintained, but it is possible this transaction 315may be undone during recovery. 316<p> 317In the case of nested transactions, if the transaction is a parent 318transaction, committing the parent transaction causes all unresolved 319children of the parent to be committed. In the case of nested 320transactions, if the transaction is a child transaction, its locks are 321not released, but are acquired by its parent. Although the commit of the 322child transaction will succeed, the actual resolution of the child 323transaction is postponed until the parent transaction is committed or 324aborted; that is, if its parent transaction commits, it will be 325committed; and if its parent transaction aborts, it will be aborted. 326<p> 327All cursors opened within the transaction must be closed before the 328transaction is committed. 329<p> 330After this method returns the <A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db"><CODE>Transaction</CODE></A> handle may not be 331accessed again, regardless of the method's success or failure. If the 332method encounters an error, the transaction and all child transactions 333of the transaction will have been aborted when the call returns. 334<p> 335<p> 336<P> 337<DD><DL> 338 339<DT><B>Throws:</B> 340<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - if a failure occurs.</DL> 341</DD> 342</DL> 343<HR> 344 345<A NAME="commitSync()"><!-- --></A><H3> 346commitSync</H3> 347<PRE> 348public void <B>commitSync</B>() 349 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE> 350<DL> 351<DD>End the transaction, committing synchronously. This means the 352transaction will exhibit all of the ACID (atomicity, consistency, 353isolation, and durability) properties. 354<p> 355This behavior is the default for database environments unless otherwise 356configured using the <A HREF="../../../com/sleepycat/db/EnvironmentConfig.html#setTxnNoSync(boolean)"><CODE>EnvironmentConfig.setTxnNoSync</CODE></A> method. This 357behavior may also be set for a single transaction using the 358<A HREF="../../../com/sleepycat/db/Environment.html#beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)"><CODE>Environment.beginTransaction</CODE></A> method. Any value specified to 359this method overrides both of those settings. 360<p> 361In the case of nested transactions, if the transaction is a parent 362transaction, committing the parent transaction causes all unresolved 363children of the parent to be committed. In the case of nested 364transactions, if the transaction is a child transaction, its locks are 365not released, but are acquired by its parent. Although the commit of the 366child transaction will succeed, the actual resolution of the child 367transaction is postponed until the parent transaction is committed or 368aborted; that is, if its parent transaction commits, it will be 369committed; and if its parent transaction aborts, it will be aborted. 370<p> 371All cursors opened within the transaction must be closed before the 372transaction is committed. 373<p> 374After this method returns the <A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db"><CODE>Transaction</CODE></A> handle may not be 375accessed again, regardless of the method's success or failure. If the 376method encounters an error, the transaction and all child transactions 377of the transaction will have been aborted when the call returns. 378<p> 379<p> 380<P> 381<DD><DL> 382 383<DT><B>Throws:</B> 384<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - if a failure occurs.</DL> 385</DD> 386</DL> 387<HR> 388 389<A NAME="commitNoSync()"><!-- --></A><H3> 390commitNoSync</H3> 391<PRE> 392public void <B>commitNoSync</B>() 393 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE> 394<DL> 395<DD>End the transaction, not committing synchronously. 396This means the 397transaction will exhibit the ACI (atomicity, consistency, and isolation) 398properties, but not D (durability); that is, database integrity will be 399maintained, but it is possible this transaction may be undone during 400recovery. 401<p> 402This behavior may be set for a database environment using the 403<A HREF="../../../com/sleepycat/db/EnvironmentConfig.html#setTxnNoSync(boolean)"><CODE>EnvironmentConfig.setTxnNoSync</CODE></A> method or for a single transaction 404using the <A HREF="../../../com/sleepycat/db/Environment.html#beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)"><CODE>Environment.beginTransaction</CODE></A> method. Any value 405specified to this method overrides both of those settings. 406<p> 407In the case of nested transactions, if the transaction is a parent 408transaction, committing the parent transaction causes all unresolved 409children of the parent to be committed. In the case of nested 410transactions, if the transaction is a child transaction, its locks are 411not released, but are acquired by its parent. Although the commit of the 412child transaction will succeed, the actual resolution of the child 413transaction is postponed until the parent transaction is committed or 414aborted; that is, if its parent transaction commits, it will be 415committed; and if its parent transaction aborts, it will be aborted. 416<p> 417All cursors opened within the transaction must be closed before the 418transaction is committed. 419<p> 420After this method returns the <A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db"><CODE>Transaction</CODE></A> handle may not be 421accessed again, regardless of the method's success or failure. If the 422method encounters an error, the transaction and all child transactions 423of the transaction will have been aborted when the call returns. 424<p> 425<p> 426<P> 427<DD><DL> 428 429<DT><B>Throws:</B> 430<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - if a failure occurs.</DL> 431</DD> 432</DL> 433<HR> 434 435<A NAME="commitWriteNoSync()"><!-- --></A><H3> 436commitWriteNoSync</H3> 437<PRE> 438public void <B>commitWriteNoSync</B>() 439 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE> 440<DL> 441<DD>End the transaction, writing but not flushing the log. 442This means the 443transaction will exhibit the ACI (atomicity, consistency, and isolation) 444properties, but not D (durability); that is, database integrity will be 445maintained, but it is possible this transaction may be undone during 446recovery in the event that the operating system crashes. This option 447provides more durability than an asynchronous commit and has less 448performance cost than a synchronous commit. 449<p> 450This behavior may be set for a database environment using the 451<A HREF="../../../com/sleepycat/db/EnvironmentConfig.html#setTxnWriteNoSync(boolean)"><CODE>EnvironmentConfig.setTxnWriteNoSync</CODE></A> method or for a single 452transaction using the <A HREF="../../../com/sleepycat/db/Environment.html#beginTransaction(com.sleepycat.db.Transaction, com.sleepycat.db.TransactionConfig)"><CODE>Environment.beginTransaction</CODE></A> method. 453Any value specified to this method overrides both of those settings. 454<p> 455In the case of nested transactions, if the transaction is a parent 456transaction, committing the parent transaction causes all unresolved 457children of the parent to be committed. In the case of nested 458transactions, if the transaction is a child transaction, its locks are 459not released, but are acquired by its parent. Although the commit of the 460child transaction will succeed, the actual resolution of the child 461transaction is postponed until the parent transaction is committed or 462aborted; that is, if its parent transaction commits, it will be 463committed; and if its parent transaction aborts, it will be aborted. 464<p> 465All cursors opened within the transaction must be closed before the 466transaction is committed. 467<p> 468After this method returns the <A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db"><CODE>Transaction</CODE></A> handle may not be 469accessed again, regardless of the method's success or failure. If the 470method encounters an error, the transaction and all child transactions 471of the transaction will have been aborted when the call returns. 472<p> 473<p> 474<P> 475<DD><DL> 476 477<DT><B>Throws:</B> 478<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - if a failure occurs.</DL> 479</DD> 480</DL> 481<HR> 482 483<A NAME="discard()"><!-- --></A><H3> 484discard</H3> 485<PRE> 486public void <B>discard</B>() 487 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE> 488<DL> 489<DD>Free up all the per-process resources associated with the specified 490 <A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db"><CODE>Transaction</CODE></A> handle, neither committing nor aborting the 491 transaction. This call may be used only after calls to 492 <A HREF="../../../com/sleepycat/db/Environment.html#recover(int, boolean)"><CODE>Environment.recover</CODE></A> when there are multiple global 493 transaction managers recovering transactions in a single database 494 environment. Any transactions returned by <A HREF="../../../com/sleepycat/db/Environment.html#recover(int, boolean)"><CODE>Environment.recover</CODE></A> that are not handled by the current global transaction 495 manager should be discarded using this method. 496 <p> 497 The <A HREF="../../../com/sleepycat/db/Transaction.html" title="class in com.sleepycat.db"><CODE>Transaction</CODE></A> handle may not be accessed again after this 498 method has been called, regardless of the method's success or failure. 499 <p> 500 <p> 501<P> 502<DD><DL> 503 504<DT><B>Throws:</B> 505<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - if a failure occurs.</DL> 506</DD> 507</DL> 508<HR> 509 510<A NAME="getId()"><!-- --></A><H3> 511getId</H3> 512<PRE> 513public int <B>getId</B>() 514 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE> 515<DL> 516<DD>Return the transaction's unique ID. 517 <p> 518 Locking calls made on behalf of this transaction should use the 519 value returned from this method as the locker parameter to the 520 <A HREF="../../../com/sleepycat/db/Environment.html#getLock(int, boolean, com.sleepycat.db.DatabaseEntry, com.sleepycat.db.LockRequestMode)"><CODE>Environment.getLock</CODE></A> or <A HREF="../../../com/sleepycat/db/Environment.html#lockVector(int, boolean, com.sleepycat.db.LockRequest[])"><CODE>Environment.lockVector</CODE></A> 521 calls. 522 <p> 523<P> 524<DD><DL> 525 526<DT><B>Returns:</B><DD>The transaction's unique ID. 527 <p> 528 <p> 529<DT><B>Throws:</B> 530<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - if a failure occurs.</DL> 531</DD> 532</DL> 533<HR> 534 535<A NAME="getName()"><!-- --></A><H3> 536getName</H3> 537<PRE> 538public <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> <B>getName</B>() 539 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE> 540<DL> 541<DD>Get the user visible name for the transaction. 542 <p> 543<P> 544<DD><DL> 545 546<DT><B>Returns:</B><DD>The user visible name for the transaction. 547 <p> 548<DT><B>Throws:</B> 549<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL> 550</DD> 551</DL> 552<HR> 553 554<A NAME="prepare(byte[])"><!-- --></A><H3> 555prepare</H3> 556<PRE> 557public void <B>prepare</B>(byte[] gid) 558 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE> 559<DL> 560<DD>Initiate the beginning of a two-phase commit. 561 <p> 562 In a distributed transaction environment, Berkeley DB can be used 563 as a local transaction manager. In this case, the distributed 564 transaction manager must send <em>prepare</em> messages to each 565 local manager. The local manager must then issue a 566 <A HREF="../../../com/sleepycat/db/Transaction.html#prepare(byte[])"><CODE>Transaction.prepare</CODE></A> call and await its successful return 567 before responding to the distributed transaction manager. Only 568 after the distributed transaction manager receives successful 569 responses from all of its <em>prepare</em> messages should it issue 570 any <em>commit</em> messages. 571 <p> 572 In the case of nested transactions, preparing the parent causes all 573 unresolved children of the parent transaction to be committed. 574 Child transactions should never be explicitly prepared. Their fate 575 will be resolved along with their parent's during global recovery. 576 <p> 577<P> 578<DD><DL> 579<DT><B>Parameters:</B><DD><CODE>gid</CODE> - The global transaction ID by which this transaction will be known. 580 This global transaction ID will be returned in calls to 581 <A HREF="../../../com/sleepycat/db/Environment.html#recover(int, boolean)"><CODE>Environment.recover</CODE></A> method, telling the application which 582 global transactions must be resolved. The gid parameter must be sized 583 at least DB_XIDDATASIZE (currently 128) bytes; only the first 584 DB_XIDDATASIZE bytes are used. 585 <p> 586 <p> 587<DT><B>Throws:</B> 588<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - if a failure occurs.</DL> 589</DD> 590</DL> 591<HR> 592 593<A NAME="setName(java.lang.String)"><!-- --></A><H3> 594setName</H3> 595<PRE> 596public void <B>setName</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> name) 597 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE> 598<DL> 599<DD>Set the user visible name for the transaction. 600 <p> 601<P> 602<DD><DL> 603<DT><B>Parameters:</B><DD><CODE>name</CODE> - The user visible name for the transaction. 604 <p> 605<DT><B>Throws:</B> 606<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE></DL> 607</DD> 608</DL> 609<HR> 610 611<A NAME="setTxnTimeout(long)"><!-- --></A><H3> 612setTxnTimeout</H3> 613<PRE> 614public void <B>setTxnTimeout</B>(long timeOut) 615 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE> 616<DL> 617<DD>Configure the timeout value for the transaction lifetime. 618 <p> 619 If the transaction runs longer than this time, the transaction may 620 may throw <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db"><CODE>DatabaseException</CODE></A>. 621 <p> 622 Timeouts are checked whenever a thread of control blocks on a lock 623 or when deadlock detection is performed. For this reason, the 624 accuracy of the timeout depends on how often deadlock detection is 625 performed. 626 <p> 627<P> 628<DD><DL> 629<DT><B>Parameters:</B><DD><CODE>timeOut</CODE> - The timeout value for the transaction lifetime, in microseconds. As 630 the value is an unsigned 32-bit number of microseconds, the maximum 631 timeout is roughly 71 minutes. A value of 0 disables timeouts for 632 the transaction. 633 <p> 634 This method may be called at any time during the life of the application. 635 <p> 636 <p> 637<DT><B>Throws:</B> 638<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - if a failure occurs.</DL> 639</DD> 640</DL> 641<HR> 642 643<A NAME="setLockTimeout(long)"><!-- --></A><H3> 644setLockTimeout</H3> 645<PRE> 646public void <B>setLockTimeout</B>(long timeOut) 647 throws <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></PRE> 648<DL> 649<DD>Configure the lock request timeout value for the transaction. 650 <p> 651 If a lock request cannot be granted in this time, the transaction 652 may throw <A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db"><CODE>DatabaseException</CODE></A>. 653 <p> 654 Timeouts are checked whenever a thread of control blocks on a lock 655 or when deadlock detection is performed. For this reason, the 656 accuracy of the timeout depends on how often deadlock detection is 657 performed. 658 <p> 659<P> 660<DD><DL> 661<DT><B>Parameters:</B><DD><CODE>timeOut</CODE> - The lock request timeout value for the transaction, in microseconds. 662 As the value is an unsigned 32-bit number of microseconds, the maximum 663 timeout is roughly 71 minutes. A value of 0 disables timeouts for the 664 transaction. 665 <p> 666 This method may be called at any time during the life of the application. 667 <p> 668 <p> 669<DT><B>Throws:</B> 670<DD><CODE><A HREF="../../../com/sleepycat/db/DatabaseException.html" title="class in com.sleepycat.db">DatabaseException</A></CODE> - if a failure occurs.</DL> 671</DD> 672</DL> 673<!-- ========= END OF CLASS DATA ========= --> 674<HR> 675 676 677<!-- ======= START OF BOTTOM NAVBAR ====== --> 678<A NAME="navbar_bottom"><!-- --></A> 679<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> 680<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> 681<TR> 682<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> 683<A NAME="navbar_bottom_firstrow"><!-- --></A> 684<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> 685 <TR ALIGN="center" VALIGN="top"> 686 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> 687 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> 688 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 689 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Transaction.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> 690 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 691 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 692 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 693 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> 694 </TR> 695</TABLE> 696</TD> 697<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> 698<b>Berkeley DB</b><br><font size="-1"> version 4.8.30</font></EM> 699</TD> 700</TR> 701 702<TR> 703<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 704 <A HREF="../../../com/sleepycat/db/StatsConfig.html" title="class in com.sleepycat.db"><B>PREV CLASS</B></A> 705 <A HREF="../../../com/sleepycat/db/TransactionConfig.html" title="class in com.sleepycat.db"><B>NEXT CLASS</B></A></FONT></TD> 706<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 707 <A HREF="../../../index.html?com/sleepycat/db/Transaction.html" target="_top"><B>FRAMES</B></A> 708 <A HREF="Transaction.html" target="_top"><B>NO FRAMES</B></A> 709 <SCRIPT type="text/javascript"> 710 <!-- 711 if(window==top) { 712 document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); 713 } 714 //--> 715</SCRIPT> 716<NOSCRIPT> 717 <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A> 718</NOSCRIPT> 719 720 721</FONT></TD> 722</TR> 723<TR> 724<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 725 SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> 726<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 727DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> 728</TR> 729</TABLE> 730<A NAME="skip-navbar_bottom"></A> 731<!-- ======== END OF BOTTOM NAVBAR ======= --> 732 733<HR> 734<font size=1>Copyright (c) 1996-2009 Oracle. All rights reserved.</font> 735</BODY> 736</HTML> 737