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