Updating the Database

Now that we've got the totals, we're ready to go ahead and save them back to the database. To do that, we'll use the principles we learned earlier in this chapter. First, in Listing 8.20, we'll lay the foundation by connecting to the database and retrieving our information from the Hashtable.

Listing 8.20. ParseOrders.java: Connecting to the Database
0:  import org.xml.sax.helpers.*;
1:  import org.xml.sax.*;
2:  import java.util.*;
3:  import java.sql.*; 4: 5: public class ParseOrders extends DefaultHandler { 6: ... 70: public void showTotals () { 71: 72: Enumeration allProducts = products.keys(); 73: while (allProducts.hasMoreElements()) { 74: String thisKey = (String)allProducts.nextElement(); 75: String thisValue = (String)products.get(thisKey); ...

Get XML and Java™ from scratch now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.