| J2EE[tm] Blueprints > Java[tm] Pet Store > 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. |
Include the Oracle JDBC driver in the J2EE Reference Implementation server classpath.
UNIX: Open the shell script
$J2EE_HOME/bin/userconfig.sh and add the full location of
the Oracle JDBC driver to the J2EE_CLASSPATH
variable.
For example, if this is /opt/oracle/jdbc/oracle.zip,
then the following lines will set the J2EE_CLASSPATH
variable appropriately:
J2EE_CLASSPATH=/opt/oracle/jdbc/oracle.zip export J2EE_CLASSPATH
Win32: Open the batch file
%J2EE_HOME%\bin\userconfig.bat and add the full location
of the Oracle JDBC driver to the J2EE_CLASSPATH
variable.
For example, if this is c:\oracle\jdbc\oracle.zip,
then the following line will set the J2EE_CLASSPATH
variable appropriately:
set J2EE_CLASSPATH=c:\oracle\jdbc\oracle.zip
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. |
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. |
Set up permissions for the application to use the Oracle database.
There are two ways to do this:
Set each enterprise bean in the application to use an existing Oracle database account.
Start the deployment tool and open the application. For each enterprise bean, select its entry in the Local Applications tree to bring up its inspector, select the Resource Ref's tabbed pane, and change the user name and password to those of an account that exists in your Oracle database.
Create a new account in the Oracle database.
The application currently uses the user name
estoreuser and password estore to access the
database. Create an account for the Oracle database which uses exactly
the same user name and password.
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. |