<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc on Wed Dec 03 16:22:06 EST 2003 --> <TITLE> TransactionRunner (Sleepycat Software, Inc. - Berkeley DB Java API) </TITLE> <META NAME="keywords" CONTENT="com.sleepycat.bdb.TransactionRunner,TransactionRunner class"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../style.css" TITLE="Style"> </HEAD> <SCRIPT> function asd() { parent.document.title="TransactionRunner (Sleepycat Software, Inc. - Berkeley DB Java API)"; } </SCRIPT> <BODY BGCOLOR="white" onload="asd();"> <!-- ========== START OF NAVBAR ========== --> <A NAME="navbar_top"><!-- --></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"> <TR> <TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/TransactionRunner.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> <b>Berkeley DB</b><br><font size="-1"> version 4.2.52</font></EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../com/sleepycat/bdb/StoredClassCatalog.html"><B>PREV CLASS</B></A> NEXT CLASS</FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="TransactionRunner.html" TARGET="_top"><B>NO FRAMES</B></A> <SCRIPT> <!-- if(window==top) { document.writeln('<A HREF="../../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <!-- =========== END OF NAVBAR =========== --> <HR> <!-- ======== START OF CLASS DATA ======== --> <H2> <FONT SIZE="-1"> com.sleepycat.bdb</FONT> <BR> Class TransactionRunner</H2> <PRE> <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html">java.lang.Object</A> | +--<B>com.sleepycat.bdb.TransactionRunner</B> </PRE> <HR> <DL> <DT>public class <B>TransactionRunner</B><DT>extends <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html">Object</A></DL> <P> Starts a transaction, calls <A HREF="../../../com/sleepycat/bdb/TransactionWorker.html#doWork()"><CODE>TransactionWorker.doWork()</CODE></A>, and handles transaction retry and exceptions. <P> <P> <HR> <P> <!-- ======== NESTED CLASS SUMMARY ======== --> <!-- =========== FIELD SUMMARY =========== --> <!-- ======== CONSTRUCTOR SUMMARY ======== --> <A NAME="constructor_summary"><!-- --></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TD COLSPAN=2><FONT SIZE="+2"> <B>Constructor Summary</B></FONT></TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE><B><A HREF="../../../com/sleepycat/bdb/TransactionRunner.html#TransactionRunner(com.sleepycat.db.DbEnv)">TransactionRunner</A></B>(<A HREF="../../../com/sleepycat/db/DbEnv.html">DbEnv</A> env)</CODE> <BR> Creates a transaction runner for a given Berkeley DB environment.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE><B><A HREF="../../../com/sleepycat/bdb/TransactionRunner.html#TransactionRunner(com.sleepycat.db.DbEnv, int)">TransactionRunner</A></B>(<A HREF="../../../com/sleepycat/db/DbEnv.html">DbEnv</A> env, int maxRetries)</CODE> <BR> Creates a transaction runner for a given Berkeley DB environment and with a given number of maximum retries.</TD> </TR> </TABLE> <!-- ========== METHOD SUMMARY =========== --> <A NAME="method_summary"><!-- --></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TD COLSPAN=2><FONT SIZE="+2"> <B>Method Summary</B></FONT></TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> boolean</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/bdb/TransactionRunner.html#getDirtyRead()">getDirtyRead</A></B>()</CODE> <BR> Returns whether transactions will read data that is modified by another transaction but not committed.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/bdb/TransactionRunner.html#getMaxRetries()">getMaxRetries</A></B>()</CODE> <BR> Returns the maximum number of retries that will be performed when deadlocks are detected.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> boolean</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/bdb/TransactionRunner.html#getNoWait()">getNoWait</A></B>()</CODE> <BR> Returns whether transactions will throw DbLockNotGrantedException instead of blocking when trying to access data that is locked by another transaction.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/bdb/TransactionRunner.html#run(com.sleepycat.bdb.TransactionWorker)">run</A></B>(<A HREF="../../../com/sleepycat/bdb/TransactionWorker.html">TransactionWorker</A> worker)</CODE> <BR> Calls the <A HREF="../../../com/sleepycat/bdb/TransactionWorker.html#doWork()"><CODE>TransactionWorker.doWork()</CODE></A> method and, for transactional environments, begins and ends a transaction.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/bdb/TransactionRunner.html#setDirtyRead(boolean)">setDirtyRead</A></B>(boolean dirtyRead)</CODE> <BR> Changes whether transactions will read data that is modified by another transaction but not committed.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/bdb/TransactionRunner.html#setMaxRetries(int)">setMaxRetries</A></B>(int maxRetries)</CODE> <BR> Changes the maximum number of retries that will be performed when deadlocks are detected.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../com/sleepycat/bdb/TransactionRunner.html#setNoWait(boolean)">setNoWait</A></B>(boolean noWait)</CODE> <BR> Changes whether transactions will throw DbLockNotGrantedException instead of blocking when trying to access data that is locked by another transaction.</TD> </TR> </TABLE> <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> <TD><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html">Object</A></B></TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE><A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html#equals(java.lang.Object)">equals</A>, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html#getClass()">getClass</A>, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html#hashCode()">hashCode</A>, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html#notify()">notify</A>, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html#notifyAll()">notifyAll</A>, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html#toString()">toString</A>, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html#wait()">wait</A>, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html#wait(long)">wait</A>, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html#wait(long, int)">wait</A></CODE></TD> </TR> </TABLE> <P> <!-- ============ FIELD DETAIL =========== --> <!-- ========= CONSTRUCTOR DETAIL ======== --> <A NAME="constructor_detail"><!-- --></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TD COLSPAN=1><FONT SIZE="+2"> <B>Constructor Detail</B></FONT></TD> </TR> </TABLE> <A NAME="TransactionRunner(com.sleepycat.db.DbEnv)"><!-- --></A><H3> TransactionRunner</H3> <PRE> public <B>TransactionRunner</B>(<A HREF="../../../com/sleepycat/db/DbEnv.html">DbEnv</A> env)</PRE> <DL> <DD>Creates a transaction runner for a given Berkeley DB environment. The default maximum number of retries (10) will be used. <P> <DT><B>Parameters:</B><DD><CODE>env</CODE> - is the environment for running transactions.</DL> <HR> <A NAME="TransactionRunner(com.sleepycat.db.DbEnv, int)"><!-- --></A><H3> TransactionRunner</H3> <PRE> public <B>TransactionRunner</B>(<A HREF="../../../com/sleepycat/db/DbEnv.html">DbEnv</A> env, int maxRetries)</PRE> <DL> <DD>Creates a transaction runner for a given Berkeley DB environment and with a given number of maximum retries. <P> <DT><B>Parameters:</B><DD><CODE>env</CODE> - is the environment for running transactions.<DD><CODE>maxRetries</CODE> - is the maximum number of retries that will be performed when deadlocks are detected.</DL> <!-- ============ METHOD DETAIL ========== --> <A NAME="method_detail"><!-- --></A> <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TD COLSPAN=1><FONT SIZE="+2"> <B>Method Detail</B></FONT></TD> </TR> </TABLE> <A NAME="getMaxRetries()"><!-- --></A><H3> getMaxRetries</H3> <PRE> public int <B>getMaxRetries</B>()</PRE> <DL> <DD>Returns the maximum number of retries that will be performed when deadlocks are detected. <P> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="setMaxRetries(int)"><!-- --></A><H3> setMaxRetries</H3> <PRE> public void <B>setMaxRetries</B>(int maxRetries)</PRE> <DL> <DD>Changes the maximum number of retries that will be performed when deadlocks are detected. Calling this method does not impact transactions already running. <P> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="getDirtyRead()"><!-- --></A><H3> getDirtyRead</H3> <PRE> public boolean <B>getDirtyRead</B>()</PRE> <DL> <DD>Returns whether transactions will read data that is modified by another transaction but not committed. <P> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="setDirtyRead(boolean)"><!-- --></A><H3> setDirtyRead</H3> <PRE> public void <B>setDirtyRead</B>(boolean dirtyRead)</PRE> <DL> <DD>Changes whether transactions will read data that is modified by another transaction but not committed. Calling this method does not impact transaction already running. <P> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="getNoWait()"><!-- --></A><H3> getNoWait</H3> <PRE> public boolean <B>getNoWait</B>()</PRE> <DL> <DD>Returns whether transactions will throw DbLockNotGrantedException instead of blocking when trying to access data that is locked by another transaction. <P> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="setNoWait(boolean)"><!-- --></A><H3> setNoWait</H3> <PRE> public void <B>setNoWait</B>(boolean noWait)</PRE> <DL> <DD>Changes whether transactions will throw DbLockNotGrantedException instead of blocking when trying to access data that is locked by another transaction. <P> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="run(com.sleepycat.bdb.TransactionWorker)"><!-- --></A><H3> run</H3> <PRE> public void <B>run</B>(<A HREF="../../../com/sleepycat/bdb/TransactionWorker.html">TransactionWorker</A> worker) throws <A HREF="../../../com/sleepycat/db/DbException.html">DbException</A>, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Exception.html">Exception</A></PRE> <DL> <DD>Calls the <A HREF="../../../com/sleepycat/bdb/TransactionWorker.html#doWork()"><CODE>TransactionWorker.doWork()</CODE></A> method and, for transactional environments, begins and ends a transaction. If the environment given is non-transactional, a transaction will not be used but the doWork() method will still be called. <p> In a transactional environment, a new transaction is started before calling doWork(). This will start a nested transaction if one is already active. If DbDeadlockException is thrown by doWork(), the transaction will be aborted and the process will be repeated up to the maximum number of retries specified. If another exception is thrown by doWork() or the maximum number of retries has occurred, the transaction will be aborted and the exception will be rethrown by this method. If no exception is thrown by doWork(), the transaction will be committed. This method will not attempt to commit or abort a transaction if it has already been committed or aborted by doWork(). </p> <P> <DD><DL> <DT><B>Throws:</B> <DD><CODE><A HREF="../../../com/sleepycat/db/DbDeadlockException.html">DbDeadlockException</A></CODE> - when it is thrown by doWork() and the maximum number of retries has occurred. The transaction will have been aborted by this method. <DD><CODE><A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Exception.html">Exception</A></CODE> - when any other exception is thrown by doWork(). The exception will first be unwrapped by calling <A HREF="../../../com/sleepycat/bdb/util/ExceptionUnwrapper.html#unwrap(java.lang.Exception)"><CODE>ExceptionUnwrapper.unwrap(java.lang.Exception)</CODE></A>. The transaction will have been aborted by this method. <DD><CODE><A HREF="../../../com/sleepycat/db/DbException.html">DbException</A></CODE></DL> </DD> </DL> <!-- ========= END OF CLASS DATA ========= --> <HR> <!-- ========== START OF NAVBAR ========== --> <A NAME="navbar_bottom"><!-- --></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"> <TR> <TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_bottom_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/TransactionRunner.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> <b>Berkeley DB</b><br><font size="-1"> version 4.2.52</font></EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../com/sleepycat/bdb/StoredClassCatalog.html"><B>PREV CLASS</B></A> NEXT CLASS</FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="TransactionRunner.html" TARGET="_top"><B>NO FRAMES</B></A> <SCRIPT> <!-- if(window==top) { document.writeln('<A HREF="../../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <!-- =========== END OF NAVBAR =========== --> <HR> <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>