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 has already been modified for you. The following changes were 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 -> 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 select Environment Entries
  8. Change the value of the sendMailConfirmation parameter from false to true
  9. Click Apply
  10. Exit AAT (File -> Save, Exit)

Deploying the Pet Store Application

Creating and Populating the Database

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

Administering the J2EE Resources

  1. Start the WebSphere Application Server
  2. Point your browser to the WebSphere Application Server Administrative Console:
    http://localhost:9090/admin
  3. Remove 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 pre-installed and enabled to use IDB. In order to enable DB2, petstore.ear with IDB must be uninstalled. 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 the WebSphere Application Server
    Note: If your UNIX environment has not been set up to run with DB2, you may need to run the DB2 default profile, prior to starting the WebSphere Application Server. If the DB2 default installation was used, run the profile by issuing this command:
    . /home/db2inst1/sqllib/db2profile


  2. Run the Pet Store Sample
    Note:  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.

    Cookies must be enabled in your browser to support Pet Store security.

Uninstalling the Pet Store Application (Optional)


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