This mini project was created in 2001 for learning/tutorial purposes and has served as the basis for many projects in my career.
It was recently retrieved from Geocities.com, one of the most popular and successful free personal web hosting services of the 1990s, which was shut down in October 2009.
Apparently all sites hosted on the service would be deleted and could not be recovered.
Thanks to Geocities for not deleting this and many of my other projects.
Demonstrates how to create and work with a Java Sax Parser in order to extract information from an XML file and store it into an Oracle database.
A company that sells CDs decides to implement a data warehouse to drive its business. They need to use a Java Sax parser to extract information from an XML file and store the data into a denormalized table created to store sales information. The example start point of this example is the program called DWSAXParser.java code and the following statement is the command to run the example:
C:> java DWSAXParser CDSales.xml
The parser code will read the data and, after the whole document is read, the parser invokes the SaleManager class to persist the objects into the database and to retrieve them and display on the console. All the codes are listed bellow
-
The Java Sax parser opens the xml file, reads its information line by line, and at the same time parse its information temporarary to variables and when the end of a sale is detected these information is transferred to a sale object that is stored in a vector.
-
After reading the whole file, the Sax parser creates a Sale Manager object that stablishes a connection to the database, then reads the vector and for each object found invokes the method "add" of the SaleManager class.
-
The objects are stored in the database and then retrieved and displayed in the screen in order to show the whole process of including and retrieving sales information from the database.
The following 7 files compose the Java Sax Parser example:
- DBProperties.txt - Contains the parameters to connect to the database.
- DSales.xml - Contains the data to be parsed.
- ctSales.sql - Contains the script to create the table Sales into Oracle database.
- DBConnection.java - Establish connection with the database.
- Sale.java - Contains the definition of class Sale.
- SaleManager.java - Manage transactions with the database like insert, update, delete.
- DWSAXParser.java - Read the XML file, parse the data and populate the database.