Using Java™ Pet Store with DB2

This scenario assumes that you are already familiar with the basics of application assembly and deployment.

Before you begin

The Pet Store application and supporting files are located in the installableApps/petstore directory: Several incompatibilities exist between WebSphere Application Server V4.0 and V1.1.2 of the petstore.ear file, available from Sun Microsystems. The petstore.ear file provided with WebSphere Application Server V4.0 is already modified for you. The following list summarizes the changes made:

Assembling the Application

Configure the petstore.ear file for use with DB2 and enable mail confirmation:
  1. Make a backup copy of the petstore.ear file
  2. Start the Application Assembly Tool (AAT):
  3. Load the the new copy of the petstore.ear file
  4. Expand petstore > EJB Modules > Customer Component > Entity Beans > TheOrder and click Environment Entries
  5. Change the value of the ejb/order/OrderDAOClass parameter to: com.ibm.j2ee.blueprints.customer.order.dao.OrderDAODB2
  6. Click Apply
  7. Expand petstore > EJB Modules > Petstore EJB Component > Session Beans > TheShoppingClientController and click Environment Entries
  8. Change the value of the sendMailConfirmation parameter from false to true
  9. Click Apply
  10. Save the new configuration by clicking File > Save
  11. Exit AAT by clicking File > Exit

Deploying the Pet Store Application

This section describes the steps to implement the Pet Store application.

Creating and Populating the Database

Locate the ps_db2.sql file in the installableApps\petstore directory. This .sql file creates and populates the required tables with data.

Administering the J2EE Resources

  1. Start WebSphere Application Server
  2. Point your browser to the WebSphere Application Server Administratrive Console:
    http://localhost:9090/admin
  3. Remove the Pet Store preconfigured Datasource:
  4. Add the Pet Store Datasource:
  5. Verify the DB2 Server class path uses the JDBC class library:
  6. Add the Pet Store Mail Session:
    Add a JavaMail session to the default mail provider. Pet Store only sends outgoing mail, so only mail transport needs configuration.
  7. Enable application-level visibility so that .wars and EJB .jars can find classes in other .wars and EJB .jars:
  8. Save your configuration and exit
  9. Shut down the WebSphere Application Server

Installing the Application

The petstore.ear comes preinstalled and enabled to use IDB. Uninstall petstore.ear with IDB in order to enable DB2. Issue the following command from a command prompt, to remove this EAR:

Now you are ready to install. Issue the following command:

Running the Application

  1. Start WebSphere Application Server
  2. Run the Pet Store Sample
    Using the back button on your browser is not recommended with Pet Store, and can cause problems. If you would like to return to a previous page in the application, use the links in the Pet Store application. For example, to return to the Main page, click on the Pet Store banner. See the official Pet Store documentation from Sun, for further details.

    You must enable cookies in your browser to support Pet Store security.

Uninstalling the Pet Store Application

Use the following instructions to uninstall the Pet Store application:
  1. Stop WebSphere Application Server
  2. Issue the following command:
  3. Drop the Pet Store database:
  4. Remove the Data Source: