Application example - IBM DB2

In this chapter, we discuss the fundamentals of application development using DB2 JDBC and guide you through the Java application development process using a small shopping cart application. This application uses the SAMPLE database shipped along with the DB2 Express-C. The application does the following:

  • Takes the customer ID as an input. Checks if the customer exists. If the customer exists, the application goes to the next page to take the order.
  • Displays all the available products. The user can select a product from the list and add it to the cart.
  • While checking out, the application gives the purchase order ID and inserts the purchase order details in the table.

The class has some of the support methods used for the application. We use this example along with others to explain how to access DB2 data. At the end of this chapter, you can follow the steps provided to run the application. This class contain the following method:

  • isCustomer(int):
  • This method checks to see if the customer ID passed to the method as an argument exists in the database or not. It returns the customer name if the id exists.
  • getProducts():
  • This method returns the name of all the available products.
  • getDescription(String):
  • This method returns the description of the product id passed as an argument.
  • createCart(HashMap):
  • This creates a cart table to store the temporary data for the cart.
  • updateTable():
  • Update the tables with the purchase order details.
  • createPorder(poid):
  • This calls a stored procedure to create the XML value.

OrderProcess class

At the end of the chapter, we use this class to make a Web application which will run on the server and implement a very simple application to create a purchase order for a shopping cart. This application can also be run as a stand-alone application. To run the application stand-alone, “Running the application”.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

IBM DB2 Topics