Using Java™ Pet Store with Oracle

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 Oracle 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 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.sun.j2ee.blueprints.customer.order.dao.OrderDAOOracle
  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 Application

Creating and Populating the Database


Locate the ps_oracle.sql file in the installableApps\petstore directory. This .sql file creates the required tables and populates them with data.
  1. Log on to the Oracle Database Server as an Oracle user
  2. Copy the ps_oracle.sql file to the Oracle Database Server
  3. Set the ORACLE_SID environment variable:
  4. Change to the directory containing the ps_oracle.sql file
  5. From the command line, sign on to Oracle SQLPlus with DBA authority
  6. Issue the command @ps_oracle.sql
    Note: The @ symbol is required in the command.
  7. Exit Oracle SQL Plus

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 Oracle JDBC Driver:
  5. Add the Pet Store Datasource:
  6. Add the Pet Store Mail Session:
    Add a JavaMail session to the default mail provider. Pet Store only sends outgoing mail, so only the 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 file comes pre-installed and enabled to use IDB. In order to enable Oracle, the 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
  2. Run the Pet Store Sample
  3. 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 Application (optional)

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