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.62.4" /> 9 <link rel="home" 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="previous" 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></div> 36 </div> 37 <div class="toc"> 38 <p> 39 <b>Table of Contents</b> 40 </p> 41 <dl> 42 <dt> 43 <span class="sect1"> 44 <a href="txnapp.html#appoverview">Application Overview</a> 45 </span> 46 </dt> 47 <dt> 48 <span class="sect1"> 49 <a href="simpleprogramlisting.html">Program Listing</a> 50 </span> 51 </dt> 52 <dd> 53 <dl> 54 <dt> 55 <span class="sect2"> 56 <a href="simpleprogramlisting.html#repconfiginfo_cxx"> 57 58 Class: RepConfig 59 </a> 60 </span> 61 </dt> 62 <dt> 63 <span class="sect2"> 64 <a href="simpleprogramlisting.html#simpletxnusage_java">Class: SimpleTxn</a> 65 </span> 66 </dt> 67 <dt> 68 <span class="sect2"> 69 <a href="simpleprogramlisting.html#simpletxnmain_java">Method: SimpleTxn.main()</a> 70 </span> 71 </dt> 72 <dt> 73 <span class="sect2"> 74 <a href="simpleprogramlisting.html#simpletxn_init_java">Method: SimpleTxn.init()</a> 75 </span> 76 </dt> 77 <dt> 78 <span class="sect2"> 79 <a href="simpleprogramlisting.html#doloop_java">Method: SimpleTxn.doloop()</a> 80 </span> 81 </dt> 82 <dt> 83 <span class="sect2"> 84 <a href="simpleprogramlisting.html#printstocks_c"> 85 86 87 Method: SimpleTxn.printStocks() 88 </a> 89 </span> 90 </dt> 91 </dl> 92 </dd> 93 </dl> 94 </div> 95 <p> 96 In this chapter, we build a simple transaction-protected DB 97 application. Throughout the remainder of this book, we will add 98 replication to this example. We do this to underscore the concepts 99 that we are presenting in this book; the first being that you 100 should start with a working transactional program and then add 101 replication to it. 102 </p> 103 <p> 104 Note that this book assumes you already know how to write a 105 transaction-protected DB application, so we will not be 106 covering those concepts in this book. To learn how to write a 107 transaction-protected application, see the 108 <i class="citetitle">Berkeley DB Getting Started with Transaction Processing</i> guide. 109 </p> 110 <div class="sect1" lang="en" xml:lang="en"> 111 <div class="titlepage"> 112 <div> 113 <div> 114 <h2 class="title" style="clear: both"><a id="appoverview"></a>Application Overview</h2> 115 </div> 116 </div> 117 <div></div> 118 </div> 119 <p> 120 Our application maintains a stock market quotes database. 121 This database contains records whose key is the stock 122 market symbol and whose data is the stock's price. 123 </p> 124 <p> 125 The application operates by presenting you with a command 126 line prompt. You then enter the stock symbol and its value, 127 separated by a space. The application takes this 128 information, writes it to the database. 129 </p> 130 <p> 131 To see the contents of the database, simply press 132 <tt class="literal">return</tt> at the command prompt. 133 </p> 134 <p> 135 To quit the application, type 'quit' or 'exit' at the 136 command prompt. 137 </p> 138 <p> 139 For example, the following illustrates the application's 140 usage. In it, we use entirely fictitious stock market 141 symbols and price values. 142 </p> 143 <pre class="programlisting">> java db.simpletxn.SimpleTxn -h env_home_dir 144QUOTESERVER> stock1 88 145QUOTESERVER> stock2 .08 146QUOTESERVER> 147 Symbol Price 148 ====== ===== 149 stock1 88 150 151QUOTESERVER> stock1 88.9 152QUOTESERVER> 153 Symbol Price 154 ====== ===== 155 stock1 88.9 156 stock2 .08 157 158QUOTESERVER> quit 159></pre> 160 </div> 161 </div> 162 <div class="navfooter"> 163 <hr /> 164 <table width="100%" summary="Navigation footer"> 165 <tr> 166 <td width="40%" align="left"><a accesskey="p" href="permmessages.html">Prev</a>��</td> 167 <td width="20%" align="center"> 168 <a accesskey="u" href="index.html">Up</a> 169 </td> 170 <td width="40%" align="right">��<a accesskey="n" href="simpleprogramlisting.html">Next</a></td> 171 </tr> 172 <tr> 173 <td width="40%" align="left" valign="top">Permanent Message Handling��</td> 174 <td width="20%" align="center"> 175 <a accesskey="h" href="index.html">Home</a> 176 </td> 177 <td width="40%" align="right" valign="top">��Program Listing</td> 178 </tr> 179 </table> 180 </div> 181 </body> 182</html> 183