J2EE[tm] Blueprints > Java[tm] Pet Store > Using databases other than Cloudscape

Using databases other than Cloudscape

The Java Pet Store is configured to use the Cloudscape database by default. This document describes how to configure the Java Pet Store to run with another database on the J2EE Reference Implementation server.


Note: The Japanese tables work with only the Cloudscape databases. They do not work with the Oracle or Sybase databases.

The examples in these instructions are for an Oracle database. (Some knowledge of Oracle is assumed.) Please note that, with slight modifications, you can use these instructions to configure the Java Pet Store to run with other databases, like Sybase.


Note: These instructions use $JPS_HOME (UNIX) and %JPS_HOME% (Win32) to denote the root directory of the J2EE Blueprints bundle.
  1. Include the Oracle JDBC driver in the J2EE Reference Implementation server classpath.

  2. Include Oracle references in the J2EE Reference Implementation server default properties.

    Open $J2EE_HOME/config/default.properties (UNIX) or %J2EE_HOME%\config\default.properties (Win32). Set the jdbc.drivers and jdbc.datasources properties to refer to the Oracle database.

    For example, if you have a standard Oracle installation on a machine dbhost and you are using the default ORCL database, then the following lines will set those properties appropriately:

    jdbc.drivers=oracle.jdbc.driver.OracleDriver
    jdbc.datasources=jdbc/Cloudscape|jdbc:oracle:thin@dbhost:1521:ORCL

    Note: These instructions assume your database is running on a machine named dbhost. You should substitute this with the name of the machine on which your database is running.
  3. Configure the customer EJB component to use the Oracle Data Access Object.

    Currently, the customer EJB component used by the application is configured to use a Cloudscape data source. In order to use this component with an Oracle database, you need to edit one of its configuration files.

    Open the file customer_ejb.xml located in $JPS_HOME/src/components/customer/src/ (UNIX) or %JPS_HOME%\src\components\customer\src\ (Win32). Look for these lines:

    <env-entry>
      <env-entry-name>ejb/order/OrderDAOClass</env-entry-name>
      <env-entry-type>java.lang.String</env-entry-type>
      <env-entry-value>com.sun.j2ee.blueprints.customer.order.dao.OrderDAOCS</env-entry-value>
    </env-entry>

    Change the value of the env-entry-value entry to the fully qualified name of the OrderDAOOracle class. You can do this by simply replacing the string OrderDAOCS with OrderDAOOracle. Once this change is made, rebuild the application.


    Note: The application also comes with a data access object for use with a Sybase database. If you are using a Sybase database, you would replace OrderDAOCS with OrderDAOSybase.
  4. Set up permissions for the application to use the Oracle database.

    There are two ways to do this:

  5. Deploy the application, install the Oracle database tables and visit the Java Pet Store.

    Once you've deployed the application, you can use the link below to go to the page which lets you install the database tables that are required by the Java Pet Store. When you get to that page, click Install Tables in the banner, and on the subsequent page, click Install Oracle Tables to install the Java Pet Store tables for your Oracle database. Please note that you are taken to this page the first time you visit the Java Pet Store.

    To install the Java Pet Store tables for the Oracle database and visit the store, click the following link:

    http://localhost:8000/estore/populate


    Note: These instructions assume that the application is deployed on a machine named localhost and port 8000. You should substitute localhost and 8000 with the name of the machine and the port on which the application is deployed.

Copyright © 2001 Sun Microsystems, Inc. All Rights Reserved.