Giter Site home page Giter Site logo

siomarapantarotto / java_sax_parser Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 83 KB

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.

Java 100.00%
java sax-parser oracle-database

java_sax_parser's Introduction

A Java Sax Parser Demo

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.

Objective:

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.

Context:

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

Steps:

  • 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.

Files:

The following 7 files compose the Java Sax Parser example:

  1. DBProperties.txt - Contains the parameters to connect to the database.
  2. DSales.xml - Contains the data to be parsed.
  3. ctSales.sql - Contains the script to create the table Sales into Oracle database.
  4. DBConnection.java - Establish connection with the database.
  5. Sale.java - Contains the definition of class Sale.
  6. SaleManager.java - Manage transactions with the database like insert, update, delete.
  7. DWSAXParser.java - Read the XML file, parse the data and populate the database.

Technologies

     

Screenshots


     

java_sax_parser's People

Contributors

siomarapantarotto avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.