Running the application - IBM DB2

The application code can be executed either stand-alone or using a Web service.

Running an application stand-alone

To run the application stand-alone, follow these steps:

  1. Set your CLASSPATH to include all the files required for JDBC
  2. Initialize the following variables in the main method:
  3. a. custid: Initialize the variable with a valid customer ID ( Exists in customer table).
    b. hm: This variable is of type HashMap. The key for the HashMap is product name and value is the quantity ordered.
  4. Start the DB2 server.
  5. Create the SAMPLE database using this command:
  6. db2sampl -xml
  7. Register the procedure created in “Stored procedure support” on to the database.
  8. Compile the Java code using the Java compiler.
  9. Run the application.

Running the application as a Web service
To run the application as a Web service, follow these steps:

  1. Install the Tomcat application server. You can obtain Tomcat from the following Web site:
  3. Install the Eclipse SDK.
  4. Install the Tomcat-eclipse plug-in.
  5. Download the application code from the IBM Redbooks Web site.
  6. Open the project in eclipse.
  7. Start the DB2 server.
  8. Create the SAMPLE database using the command:
  9. db2sampl -xml
  10. Register the procedure created in “Stored procedure support” to the sample database.
  11. Start the Tomcat server.
  12. Point your browser to this link:
  13. http://localhost:8080/cart/default.jsp

If Tomcat and the application are downloaded onto a remote machine, give the machine IP address/name instead of localhost.

Note: The previous project can be run using any application server. We recommend Tomcat and Eclipse, because we used them to create the application.

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

IBM DB2 Topics