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>Database Usage Example</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 Berkeley DB" /> 10 <link rel="up" href="DBEntry.html" title="Chapter��8.��Database Records" /> 11 <link rel="prev" href="bindAPI.html" title="Using the BIND APIs" /> 12 <link rel="next" href="Cursors.html" title="Chapter��9.��Using Cursors" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">Database Usage Example</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="bindAPI.html">Prev</a>��</td> 22 <th width="60%" align="center">Chapter��8.��Database Records</th> 23 <td width="20%" align="right">��<a accesskey="n" href="Cursors.html">Next</a></td> 24 </tr> 25 </table> 26 <hr /> 27 </div> 28 <div class="sect1" lang="en" xml:lang="en"> 29 <div class="titlepage"> 30 <div> 31 <div> 32 <h2 class="title" style="clear: both"><a id="dbtJavaUsage"></a>Database Usage Example</h2> 33 </div> 34 </div> 35 </div> 36 <p> 37 In <a class="xref" href="CoreJavaUsage.html#MyDb" title="Example 7.1 MyDbs Class">MyDbs Class</a> we created 38 a class that opens and closes databases for us. 39 We now make use of that class to load inventory data into 40 two databases that we will use for our inventory system. 41 </p> 42 <p> 43 Again, remember that you can find the complete implementation for these functions 44 in: 45 </p> 46 <pre class="programlisting"><span class="emphasis"><em>DB_INSTALL</em></span>/examples_java/db/GettingStarted</pre> 47 <p> 48 where <code class="literal"><span class="emphasis"><em>DB_INSTALL</em></span></code> is the location where you 49 placed your DB distribution. 50 </p> 51 <p>Note that in this example, we are going to save two types of 52 information. First there are a series of inventory records that identify 53 information about some food items (fruits, vegetables, and desserts). 54 These records identify particulars about each item such as the vendor that 55 the item can be obtained from, how much the vendor has in stock, the price 56 per unit, and so forth.</p> 57 <p> 58 We also want to manage vendor contact information, such as the 59 vendor's address and phone number, the sales representative's name 60 and his phone number, and so forth. 61 </p> 62 <div class="example"> 63 <a id="inventoryjava"></a> 64 <p class="title"> 65 <b>Example 8.1 Inventory.java</b> 66 </p> 67 <div class="example-contents"> 68 <p> 69 All Inventory data is encapsulated in an instance of the following 70 class. Note that because this class is not serializable, we need a 71 custom tuple binding in order to place it on a <code class="classname">DatabaseEntry</code> 72 object. Because the <code class="classname">TupleInput</code> and 73 <code class="classname">TupleOutput</code> classes used by custom tuple bindings 74 support Java numerical types and not Java numerical classes, we use 75 <code class="literal">int</code> and <code class="literal">float</code> here instead of the 76 corresponding <code class="classname">Integer</code> and <code class="classname">Float</code> 77 classes. 78 79 </p> 80 <a id="java_dbt16"></a> 81 <pre class="programlisting">// File Inventory.java 82package db.GettingStarted; 83 84public class Inventory { 85 86 private String sku; 87 private String itemName; 88 private String category; 89 private String vendor; 90 private int vendorInventory; 91 private float vendorPrice; 92 93 public void setSku(String data) { 94 sku = data; 95 } 96 97 public void setItemName(String data) { 98 itemName = data; 99 } 100 101 public void setCategory(String data) { 102 category = data; 103 } 104 105 public void setVendorInventory(int data) { 106 vendorInventory = data; 107 } 108 109 public void setVendor(String data) { 110 vendor = data; 111 } 112 113 public void setVendorPrice(float data) { 114 vendorPrice = data; 115 } 116 117 public String getSku() { return sku; } 118 public String getItemName() { return itemName; } 119 public String getCategory() { return category; } 120 public int getVendorInventory() { return vendorInventory; } 121 public String getVendor() { return vendor; } 122 public float getVendorPrice() { return vendorPrice; } 123 124} </pre> 125 </div> 126 </div> 127 <br class="example-break" /> 128 <div class="example"> 129 <a id="vendorjava"></a> 130 <p class="title"> 131 <b>Example 8.2 Vendor.java</b> 132 </p> 133 <div class="example-contents"> 134 <p> 135 The data for vendor records are stored in instances of the following 136 class. Notice that we are using serialization with this class for no 137 other reason than to demonstrate serializing a class instance. 138 </p> 139 <a id="java_dbt17"></a> 140 <pre class="programlisting">// File Vendor.java 141package db.GettingStarted; 142 143import java.io.Serializable; 144 145public class Vendor implements Serializable { 146 147 private String repName; 148 private String address; 149 private String city; 150 private String state; 151 private String zipcode; 152 private String bizPhoneNumber; 153 private String repPhoneNumber; 154 private String vendor; 155 156 public void setRepName(String data) { 157 repName = data; 158 } 159 160 public void setAddress(String data) { 161 address = data; 162 } 163 164 public void setCity(String data) { 165 city = data; 166 } 167 168 public void setState(String data) { 169 state = data; 170 } 171 172 public void setZipcode(String data) { 173 zipcode = data; 174 } 175 176 public void setBusinessPhoneNumber(String data) { 177 bizPhoneNumber = data; 178 } 179 180 public void setRepPhoneNumber(String data) { 181 repPhoneNumber = data; 182 } 183 184 public void setVendorName(String data) { 185 vendor = data; 186 } 187 188 ... 189 // Corresponding getter methods omitted for brevity. 190 // See examples/je/gettingStarted/Vendor.java 191 // for a complete implementation of this class. 192 193} </pre> 194 </div> 195 </div> 196 <br class="example-break" /> 197 <p> 198 Because we will not be using serialization to convert our 199 <code class="classname">Inventory</code> objects to a <code class="classname">DatabaseEntry</code> 200 object, we need a custom tuple binding: 201 </p> 202 <div class="example"> 203 <a id="InventoryJavaBinding"></a> 204 <p class="title"> 205 <b>Example 8.3 InventoryBinding.java</b> 206 </p> 207 <div class="example-contents"> 208 <a id="java_dbt18"></a> 209 <pre class="programlisting">// File InventoryBinding.java 210package db.GettingStarted; 211 212import com.sleepycat.bind.tuple.TupleBinding; 213import com.sleepycat.bind.tuple.TupleInput; 214import com.sleepycat.bind.tuple.TupleOutput; 215 216public class InventoryBinding extends TupleBinding { 217 218 // Implement this abstract method. Used to convert 219 // a DatabaseEntry to an Inventory object. 220 public Object entryToObject(TupleInput ti) { 221 222 String sku = ti.readString(); 223 String itemName = ti.readString(); 224 String category = ti.readString(); 225 String vendor = ti.readString(); 226 int vendorInventory = ti.readInt(); 227 float vendorPrice = ti.readFloat(); 228 229 Inventory inventory = new Inventory(); 230 inventory.setSku(sku); 231 inventory.setItemName(itemName); 232 inventory.setCategory(category); 233 inventory.setVendor(vendor); 234 inventory.setVendorInventory(vendorInventory); 235 inventory.setVendorPrice(vendorPrice); 236 237 return inventory; 238 } 239 240 // Implement this abstract method. Used to convert a 241 // Inventory object to a DatabaseEntry object. 242 public void objectToEntry(Object object, TupleOutput to) { 243 244 Inventory inventory = (Inventory)object; 245 246 to.writeString(inventory.getSku()); 247 to.writeString(inventory.getItemName()); 248 to.writeString(inventory.getCategory()); 249 to.writeString(inventory.getVendor()); 250 to.writeInt(inventory.getVendorInventory()); 251 to.writeFloat(inventory.getVendorPrice()); 252 } 253} </pre> 254 </div> 255 </div> 256 <br class="example-break" /> 257 <p> 258 In order to store the data identified above, we write the 259 <code class="classname">ExampleDatabaseLoad</code> application. This application 260 loads the inventory and vendor databases for you. 261 </p> 262 <p> 263 Inventory information is stored in a <code class="classname">Database</code> 264 dedicated for that purpose. The key for each such record is a product 265 SKU. The inventory data stored in this database are objects of the 266 <code class="classname">Inventory</code> class (see <a class="xref" href="dbtJavaUsage.html#inventoryjava" title="Example 8.1 Inventory.java">Inventory.java</a> for more information). 267 <code class="classname">ExampleDatabaseLoad</code> loads the inventory database 268 as follows: 269 </p> 270 <div class="orderedlist"> 271 <ol type="1"> 272 <li> 273 <p> 274 Reads the inventory data from a flat text file prepared in 275 advance for this purpose. 276 </p> 277 </li> 278 <li> 279 <p> 280 Uses <code class="classname">java.lang.String</code> to create a key based 281 on the item's SKU. 282 </p> 283 </li> 284 <li> 285 <p>Uses an <code class="classname">Inventory</code> class instance for the 286 record data. This object is stored on a <code class="classname">DatabaseEntry</code> 287 object using <code class="classname">InventoryBinding</code>, a custom tuple 288 binding that we implemented above.</p> 289 </li> 290 <li> 291 <p>Saves each record to the inventory database.</p> 292 </li> 293 </ol> 294 </div> 295 <p>Vendor information is also stored in a <code class="classname">Database</code> 296 dedicated for that purpose. The vendor data stored in this database are objects of the 297 <code class="classname">Vendor</code> class (see <a class="xref" href="dbtJavaUsage.html#vendorjava" title="Example 8.2 Vendor.java">Vendor.java</a> for more information). To load this 298 <code class="classname">Database</code>, <code class="classname">ExampleDatabaseLoad</code> 299 does the following:</p> 300 <div class="orderedlist"> 301 <ol type="1"> 302 <li> 303 <p>Reads the vendor data from a flat text file prepared in advance 304 for this purpose.</p> 305 </li> 306 <li> 307 <p>Uses the vendor's name as the record's key.</p> 308 </li> 309 <li> 310 <p>Uses a <code class="classname">Vendor</code> class instance for the 311 record data. This object is stored on a <code class="classname">DatabaseEntry</code> 312 object using <code class="classname">com.sleepycat.bind.serial.SerialBinding</code>.</p> 313 </li> 314 </ol> 315 </div> 316 <div class="example"> 317 <a id="dbsStoredClass"></a> 318 <p class="title"> 319 <b>Example 8.4 Stored Class Catalog Management with MyDbs</b> 320 </p> 321 <div class="example-contents"> 322 <p> 323 Before we can write <code class="classname">ExampleDatabaseLoad</code>, we need to update 324 <code class="filename">MyDbs.java</code> to support the class catalogs that we need for this application. 325 </p> 326 <p> 327 To do this, we start by importing an additional class to support stored class catalogs: 328 </p> 329 <a id="java_dbt19"></a> 330 <pre class="programlisting">// File: MyDbs.java 331package db.GettingStarted; 332 333<strong class="userinput"><code>import com.sleepycat.bind.serial.StoredClassCatalog;</code></strong> 334 335import com.sleepycat.db.Database; 336import com.sleepycat.db.DatabaseConfig; 337import com.sleepycat.db.DatabaseException; 338import com.sleepycat.db.DatabaseType; 339 340import java.io.FileNotFoundException; </pre> 341 <p> 342 We also need to add two additional private data members to this class. One 343 supports the database used for the class catalog, and the other is used as a 344 handle for the class catalog itself. 345</p> 346 <a id="java_dbt20"></a> 347 <pre class="programlisting">public class MyDbs { 348 349 // The databases that our application uses 350 private Database vendorDb = null; 351 private Database inventoryDb = null; 352 <strong class="userinput"><code>private Database classCatalogDb = null; 353 354 // Needed for object serialization 355 private StoredClassCatalog classCatalog;</code></strong> 356 357 private String vendordb = "VendorDB.db"; 358 private String inventorydb = "InventoryDB.db"; 359 <strong class="userinput"><code>private String classcatalogdb = "ClassCatalogDB.db";</code></strong> 360 361 // Our constructor does nothing 362 public MyDbs() {} </pre> 363 <p> 364 Next we need to update the <code class="methodname">MyDbs.setup()</code> method 365 to open the class catalog database and create the class catalog. 366 </p> 367 <a id="java_dbt21"></a> 368 <pre class="programlisting"> // The setup() method opens all our databases 369 // for us. 370 public void setup(String databasesHome) 371 throws DatabaseException { 372 373 DatabaseConfig myDbConfig = new DatabaseConfig(); 374 375 ... 376 // Database configuration omitted for brevity 377 ... 378 379 // Now open, or create and open, our databases 380 // Open the vendors and inventory databases 381 try { 382 vendordb = databasesHome + "/" + vendordb; 383 vendorDb = new Database(vendordb, 384 null, 385 myDbConfig); 386 387 inventorydb = databasesHome + "/" + inventorydb; 388 inventoryDb = new Database(inventorydb, 389 null, 390 myDbConfig); 391 392 <strong class="userinput"><code>// Open the class catalog db. This is used to 393 // optimize class serialization. 394 classcatalogdb = databasesHome + "/" + classcatalogdb; 395 classCatalogDb = new Database(classcatalogdb, 396 null, 397 myDbConfig); </code></strong> 398 399 } catch(FileNotFoundException fnfe) { 400 System.err.println("MyDbs: " + fnfe.toString()); 401 System.exit(-1); 402 } 403 } </pre> 404 <p> 405 Finally we need a getter method to return the class catalog. Note that we do not provide a getter for 406 the catalog database itself ��� our application has no need for that. 407 </p> 408 <p> 409 We also update our <code class="methodname">close()</code> to close our class catalog. 410 </p> 411 <a id="java_dbt22"></a> 412 <pre class="programlisting"> // getter methods 413 public Database getVendorDB() { 414 return vendorDb; 415 } 416 417 public Database getInventoryDB() { 418 return inventoryDb; 419 } 420 421 <strong class="userinput"><code>public StoredClassCatalog getClassCatalog() { 422 return classCatalog; 423 }</code></strong> 424</pre> 425 <p> 426 Finally, we need our <code class="methodname">close()</code> method: 427</p> 428 <a id="java_dbt23"></a> 429 <pre class="programlisting"> 430 431 // Close the databases 432 public void close() { 433 try { 434 if (vendorDb != null) { 435 vendorDb.close(); 436 } 437 438 if (inventoryDb != null) { 439 inventoryDb.close(); 440 } 441 442 <strong class="userinput"><code>if (classCatalogDb != null) { 443 classCatalogDb.close(); 444 }</code></strong> 445 } catch(DatabaseException dbe) { 446 System.err.println("Error closing MyDbs: " + 447 dbe.toString()); 448 System.exit(-1); 449 } 450 } 451} </pre> 452 </div> 453 </div> 454 <br class="example-break" /> 455 <p> 456 So far we have identified the data that we want to store in our 457 databases and how we will convert that data in and out of 458 <code class="classname">DatabaseEntry</code> objects for database storage. We 459 have also updated <code class="classname">MyDbs</code> to manage our databases 460 for us. Now we write <code class="classname">ExampleDatabaseLoad</code> to 461 actually put the inventory and vendor data into their respective 462 databases. Because of the work that we have done so far, this 463 application is actually fairly simple to write. 464 </p> 465 <div class="example"> 466 <a id="EDL"></a> 467 <p class="title"> 468 <b>Example 8.5 ExampleDatabaseLoad.java</b> 469 </p> 470 <div class="example-contents"> 471 <p>First we need the usual series of import statements:</p> 472 <a id="java_dbt24"></a> 473 <pre class="programlisting">// File: ExampleDatabaseLoad.java 474package db.GettingStarted; 475 476import java.io.BufferedReader; 477import java.io.File; 478import java.io.FileInputStream; 479import java.io.FileNotFoundException; 480import java.io.IOException; 481import java.io.InputStreamReader; 482import java.util.ArrayList; 483import java.util.List; 484 485import com.sleepycat.bind.EntryBinding; 486import com.sleepycat.bind.serial.SerialBinding; 487import com.sleepycat.bind.tuple.TupleBinding; 488import com.sleepycat.db.DatabaseEntry; 489import com.sleepycat.db.DatabaseException; </pre> 490 <p>Next comes the class declaration and the private data members that 491 we need for this class. Most of these are setting up default values for 492 the program.</p> 493 <p>Note that two <code class="classname">DatabaseEntry</code> objects are 494 instantiated here. We will reuse these for every database operation that 495 this program performs. Also a <code class="classname">MyDbEnv</code> object is 496 instantiated here. We can do this because its constructor never throws 497 an exception. See <a class="xref" href="dbtJavaUsage.html#dbsStoredClass" title="Example 8.4 Stored Class Catalog Management with MyDbs">Stored Class Catalog Management with MyDbs</a> for 498 its implementation details.</p> 499 <p>Finally, the <code class="filename">inventory.txt</code> and 500 <code class="filename">vendors.txt</code> file can be found in the GettingStarted 501 examples directory along with the classes described in this extended 502 example.</p> 503 <a id="java_dbt25"></a> 504 <pre class="programlisting">public class ExampleDatabaseLoad { 505 506 private static String myDbsPath = "./"; 507 private static File inventoryFile = new File("./inventory.txt"); 508 private static File vendorsFile = new File("./vendors.txt"); 509 510 // DatabaseEntries used for loading records 511 private static DatabaseEntry theKey = new DatabaseEntry(); 512 private static DatabaseEntry theData = new DatabaseEntry(); 513 514 // Encapsulates the databases. 515 private static MyDbs myDbs = new MyDbs(); </pre> 516 <p> 517 Next comes the <code class="methodname">usage()</code> and 518 <code class="methodname">main()</code> methods. Notice the exception handling 519 in the <code class="methodname">main()</code> method. This is the only place in the application where we 520 catch exceptions. For this reason, we must catch 521 <code class="classname">DatabaseException</code> which is thrown by the 522 <code class="literal">com.sleepycat.db.*</code> classes. 523 </p> 524 <p>Also notice the call to <code class="methodname">MyDbs.close()</code> 525 in the <code class="literal">finally</code> block. This is the only place in the 526 application where <code class="methodname">MyDbs.close()</code> is called. 527 <code class="methodname">MyDbs.close()</code> is responsible for closing 528 all open <code class="classname">Database</code> 529 handles for you.</p> 530 <a id="java_dbt26"></a> 531 <pre class="programlisting"> private static void usage() { 532 System.out.println("ExampleDatabaseLoad [-h <database home>]"); 533 System.out.println(" [-s <selections file>] [-v <vendors file>]"); 534 System.exit(-1); 535 } 536 537 public static void main(String args[]) { 538 ExampleDatabaseLoad edl = new ExampleDatabaseLoad(); 539 try { 540 edl.run(args); 541 } catch (DatabaseException dbe) { 542 System.err.println("ExampleDatabaseLoad: " + dbe.toString()); 543 dbe.printStackTrace(); 544 } catch (Exception e) { 545 System.out.println("Exception: " + e.toString()); 546 e.printStackTrace(); 547 } finally { 548 myDbs.close(); 549 } 550 System.out.println("All done."); 551 } </pre> 552 <p>Next we write the <code class="methodname">ExampleDatabaseLoad.run()</code> 553 method. This method is responsible for initializing all objects. 554 Because our environment and databases are all opened using the 555 <code class="methodname">MyDbs.setup()</code> method, <code class="methodname">ExampleDatabaseLoad.run()</code> 556 method is only responsible for calling <code class="methodname">MyDbs.setup()</code> and then calling 557 the <code class="classname">ExampleDatabaseLoad</code> methods that actually load the databases. 558 </p> 559 <a id="java_dbt27"></a> 560 <pre class="programlisting"> private void run(String args[]) throws DatabaseException { 561 // Parse the arguments list 562 parseArgs(args); 563 564 myDbs.setup(myDbsPath); // path to the environment home 565 566 System.out.println("loading vendors db."); 567 loadVendorsDb(); 568 System.out.println("loading inventory db."); 569 loadInventoryDb(); 570 } </pre> 571 <p>This next method loads the vendor database. This method 572 uses serialization to convert the <code class="classname">Vendor</code> object 573 to a <code class="classname">DatabaseEntry</code> object.</p> 574 <a id="java_dbt28"></a> 575 <pre class="programlisting"> private void loadVendorsDb() 576 throws DatabaseException { 577 578 // loadFile opens a flat-text file that contains our data 579 // and loads it into a list for us to work with. The integer 580 // parameter represents the number of fields expected in the 581 // file. 582 List vendors = loadFile(vendorsFile, 8); 583 584 // Now load the data into the database. The vendor's name is the 585 // key, and the data is a Vendor class object. 586 587 // Need a serial binding for the data 588 EntryBinding dataBinding = 589 new SerialBinding(myDbs.getClassCatalog(), Vendor.class); 590 591 for (int i = 0; i < vendors.size(); i++) { 592 String[] sArray = (String[])vendors.get(i); 593 Vendor theVendor = new Vendor(); 594 theVendor.setVendorName(sArray[0]); 595 theVendor.setAddress(sArray[1]); 596 theVendor.setCity(sArray[2]); 597 theVendor.setState(sArray[3]); 598 theVendor.setZipcode(sArray[4]); 599 theVendor.setBusinessPhoneNumber(sArray[5]); 600 theVendor.setRepName(sArray[6]); 601 theVendor.setRepPhoneNumber(sArray[7]); 602 603 // The key is the vendor's name. 604 // ASSUMES THE VENDOR'S NAME IS UNIQUE! 605 String vendorName = theVendor.getVendorName(); 606 try { 607 theKey = new DatabaseEntry(vendorName.getBytes("UTF-8")); 608 } catch (IOException willNeverOccur) {} 609 610 // Convert the Vendor object to a DatabaseEntry object 611 // using our SerialBinding 612 dataBinding.objectToEntry(theVendor, theData); 613 614 // Put it in the database. 615 myDbs.getVendorDB().put(null, theKey, theData); 616 } 617 } </pre> 618 <p>Now load the inventory database. This method uses our 619 custom tuple binding (see <a class="xref" href="dbtJavaUsage.html#InventoryJavaBinding" title="Example 8.3 InventoryBinding.java">InventoryBinding.java</a>) to convert the <code class="classname">Inventory</code> 620 object to a <code class="classname">DatabaseEntry</code> object.</p> 621 <a id="java_dbt29"></a> 622 <pre class="programlisting"> private void loadInventoryDb() 623 throws DatabaseException { 624 625 // loadFile opens a flat-text file that contains our data 626 // and loads it into a list for us to work with. The integer 627 // parameter represents the number of fields expected in the 628 // file. 629 List inventoryArray = loadFile(inventoryFile, 6); 630 631 // Now load the data into the database. The item's sku is the 632 // key, and the data is an Inventory class object. 633 634 // Need a tuple binding for the Inventory class. 635 TupleBinding inventoryBinding = new InventoryBinding(); 636 637 for (int i = 0; i < inventoryArray.size(); i++) { 638 String[] sArray = (String[])inventoryArray.get(i); 639 String sku = sArray[1]; 640 try { 641 theKey = new DatabaseEntry(sku.getBytes("UTF-8")); 642 } catch (IOException willNeverOccur) {} 643 644 Inventory theInventory = new Inventory(); 645 theInventory.setItemName(sArray[0]); 646 theInventory.setSku(sArray[1]); 647 Float price = new Float(sArray[2]); 648 theInventory.setVendorPrice(price.floatValue()); 649 Integer vInventory = new Integer(sArray[3]); 650 theInventory.setVendorInventory(vInventory.intValue()); 651 theInventory.setCategory(sArray[4]); 652 theInventory.setVendor(sArray[5]); 653 654 // Place the Vendor object on the DatabaseEntry object using 655 // our the tuple binding we implemented in 656 // InventoryBinding.java 657 inventoryBinding.objectToEntry(theInventory, theData); 658 659 // Put it in the database. Note that this causes our 660 // secondary database to be automatically updated for us. 661 myDbs.getInventoryDB().put(null, theKey, theData); 662 } 663 }</pre> 664 <p> 665 The remainder of this application provides utility methods to 666 read a flat text file into an array of strings and parse the 667 command line options: 668 </p> 669 <a id="java_dbt30"></a> 670 <pre class="programlisting"> private static void parseArgs(String args[]) { 671 // Implementation omitted for brevity. 672 } 673 674 private List loadFile(File theFile, int numFields) { 675 List records = new ArrayList(); 676 // Implementation omitted for brevity. 677 return records; 678 } 679 680 protected ExampleDatabaseLoad() {} 681} </pre> 682 <p> 683 From the perspective of this document, these 684 things are relatively uninteresting. You can see how they are 685 implemented by looking at <code class="filename">ExampleDatabaseLoad.java</code> 686 in: 687 </p> 688 <pre class="programlisting"><span class="emphasis"><em>DB_INSTALL</em></span>/examples_java/db/GettingStarted</pre> 689 <p> 690 where <code class="literal"><span class="emphasis"><em>DB_INSTALL</em></span></code> is the location where you 691 placed your DB distribution. 692 </p> 693 </div> 694 </div> 695 <br class="example-break" /> 696 </div> 697 <div class="navfooter"> 698 <hr /> 699 <table width="100%" summary="Navigation footer"> 700 <tr> 701 <td width="40%" align="left"><a accesskey="p" href="bindAPI.html">Prev</a>��</td> 702 <td width="20%" align="center"> 703 <a accesskey="u" href="DBEntry.html">Up</a> 704 </td> 705 <td width="40%" align="right">��<a accesskey="n" href="Cursors.html">Next</a></td> 706 </tr> 707 <tr> 708 <td width="40%" align="left" valign="top">Using the BIND APIs��</td> 709 <td width="20%" align="center"> 710 <a accesskey="h" href="index.html">Home</a> 711 </td> 712 <td width="40%" align="right" valign="top">��Chapter��9.��Using Cursors</td> 713 </tr> 714 </table> 715 </div> 716 </body> 717</html> 718