1<?xml version="1.0" encoding="UTF-8" standalone="no"?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 6 <title>Chapter��2.��Transactional Application</title> 7 <link rel="stylesheet" href="gettingStarted.css" type="text/css" /> 8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> 9 <link rel="start" href="index.html" title="Getting Started with Replicated Berkeley DB Applications" /> 10 <link rel="up" href="index.html" title="Getting Started with Replicated Berkeley DB Applications" /> 11 <link rel="prev" href="permmessages.html" title="Permanent Message Handling" /> 12 <link rel="next" href="simpleprogramlisting.html" title="Program Listing" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">Chapter��2.��Transactional Application</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="permmessages.html">Prev</a>��</td> 22 <th width="60%" align="center">��</th> 23 <td width="20%" align="right">��<a accesskey="n" href="simpleprogramlisting.html">Next</a></td> 24 </tr> 25 </table> 26 <hr /> 27 </div> 28 <div class="chapter" lang="en" xml:lang="en"> 29 <div class="titlepage"> 30 <div> 31 <div> 32 <h2 class="title"><a id="txnapp"></a>Chapter��2.��Transactional Application</h2> 33 </div> 34 </div> 35 </div> 36 <div class="toc"> 37 <p> 38 <b>Table of Contents</b> 39 </p> 40 <dl> 41 <dt> 42 <span class="sect1"> 43 <a href="txnapp.html#appoverview">Application Overview</a> 44 </span> 45 </dt> 46 <dt> 47 <span class="sect1"> 48 <a href="simpleprogramlisting.html">Program Listing</a> 49 </span> 50 </dt> 51 <dd> 52 <dl> 53 <dt> 54 <span class="sect2"> 55 <a href="simpleprogramlisting.html#repconfiginfo_cxx"> 56 57 <span>Class: RepConfig</span> 58 </a> 59 </span> 60 </dt> 61 <dt> 62 <span class="sect2"> 63 <a href="simpleprogramlisting.html#simpletxnusage_java">Class: SimpleTxn</a> 64 </span> 65 </dt> 66 <dt> 67 <span class="sect2"> 68 <a href="simpleprogramlisting.html#simpletxnmain_java">Method: SimpleTxn.main()</a> 69 </span> 70 </dt> 71 <dt> 72 <span class="sect2"> 73 <a href="simpleprogramlisting.html#simpletxn_init_java">Method: SimpleTxn.init()</a> 74 </span> 75 </dt> 76 <dt> 77 <span class="sect2"> 78 <a href="simpleprogramlisting.html#doloop_java">Method: SimpleTxn.doloop()</a> 79 </span> 80 </dt> 81 <dt> 82 <span class="sect2"> 83 <a href="simpleprogramlisting.html#printstocks_c"> 84 85 86 <span>Method: SimpleTxn.printStocks()</span> 87 </a> 88 </span> 89 </dt> 90 </dl> 91 </dd> 92 </dl> 93 </div> 94 <p> 95 In this chapter, we build a simple transaction-protected DB 96 application. Throughout the remainder of this book, we will add 97 replication to this example. We do this to underscore the concepts 98 that we are presenting in this book; the first being that you 99 should start with a working transactional program and then add 100 replication to it. 101 </p> 102 <p> 103 Note that this book assumes you already know how to write a 104 transaction-protected DB application, so we will not be 105 covering those concepts in this book. To learn how to write a 106 transaction-protected application, see the 107 <em class="citetitle">Berkeley DB Getting Started with Transaction Processing</em> guide. 108 </p> 109 <div class="sect1" lang="en" xml:lang="en"> 110 <div class="titlepage"> 111 <div> 112 <div> 113 <h2 class="title" style="clear: both"><a id="appoverview"></a>Application Overview</h2> 114 </div> 115 </div> 116 </div> 117 <p> 118 Our application maintains a stock market quotes database. 119 This database contains records whose key is the stock 120 market symbol and whose data is the stock's price. 121 </p> 122 <p> 123 The application operates by presenting you with a command 124 line prompt. You then enter the stock symbol and its value, 125 separated by a space. The application takes this 126 information and writes it to the database. 127 </p> 128 <p> 129 To see the contents of the database, simply press 130 <code class="literal">return</code> at the command prompt. 131 </p> 132 <p> 133 To quit the application, type 'quit' or 'exit' at the 134 command prompt. 135 </p> 136 <p> 137 For example, the following illustrates the application's 138 usage. In it, we use entirely fictitious stock market 139 symbols and price values. 140 </p> 141 <pre class="programlisting">> java db.repquote_gsg.SimpleTxn -h env_home_dir 142QUOTESERVER> stock1 88 143QUOTESERVER> stock2 .08 144QUOTESERVER> 145 Symbol Price 146 ====== ===== 147 stock1 88 148 149QUOTESERVER> stock1 88.9 150QUOTESERVER> 151 Symbol Price 152 ====== ===== 153 stock1 88.9 154 stock2 .08 155 156QUOTESERVER> quit 157></pre> 158 </div> 159 </div> 160 <div class="navfooter"> 161 <hr /> 162 <table width="100%" summary="Navigation footer"> 163 <tr> 164 <td width="40%" align="left"><a accesskey="p" href="permmessages.html">Prev</a>��</td> 165 <td width="20%" align="center">��</td> 166 <td width="40%" align="right">��<a accesskey="n" href="simpleprogramlisting.html">Next</a></td> 167 </tr> 168 <tr> 169 <td width="40%" align="left" valign="top">Permanent Message Handling��</td> 170 <td width="20%" align="center"> 171 <a accesskey="h" href="index.html">Home</a> 172 </td> 173 <td width="40%" align="right" valign="top">��Program Listing</td> 174 </tr> 175 </table> 176 </div> 177 </body> 178</html> 179