J2EE Blueprints

Java TM Pet Store Demo

 switching databases
   configuring the javaTM pet store for oracle
 
This document describes how to configure the Java Pet Store to run with an Oracle database. Some knowledge of Oracle is assumed.
  1. Include the Oracle JDBC driver in the J2EE_CLASSPATH.
    Note: You must perform this step before you start the j2ee server.

    On Unix systems:
    Add the Oracle JDBC driver to the CLASSPATH variable in the file $J2EE_HOME/bin/userconfig.sh.

    • Uncomment the following line in $J2EE_HOME/bin/userconfig.sh, and add your driver archive file name:
      J2EE_CLASSPATH=/home/yourhome/oracle.zip
    • Uncomment the line that reads:
      export J2EE_CLASSPATH

    On Windows systems:
    Include the JDBC driver in the CLASSPATH in %J2EE_HOME%\bin\userconfig.bat

    • Uncomment the following line in %J2EE_HOME%\bin\userconfig.bat, and add your drive archive file name:
      J2EE_CLASSPATH=c:\oracle.zip
  2. Add Oracle to default.properties
    You need to set the jdbc.drivers and jdbc.datasources properties to refer to the Oracle DB. If you have a standard version of Oracle installed on your machine and you are using the default ORCL database, the following lines of code will work:
          jdbc.drivers=oracle.jdbc.driver.OracleDriver
          jdbc.datasources=jdbc/EstoreDB|jdbc:oracle:thin:@localhost:1521:ORCL|
             jdbc/InventoryDB|jdbc:oracle:thin:@localhost:1521:ORCL

    NOTE: The second and third lines above, setting jdbc.datasources, should be on a single line in the default.properties file.

  3. Set up user permissions
    You will need either to change the user name and password for each enterprise bean resource reference in your application, or create a new user account in your target Oracle database.
    • Change the user name/password in the deploytool by clicking on each enterprise bean and then the ResourceReference tab. The default username is set to estoreuser and the password is set to estore.
    • An alternative is to create a new user called estoreuser with the password of estore in your target database.
  4. Create the database schema and load the application data.
    Load the tables from the oracle.sql script into your target database. Please note the "@" character is part of the command. From sqlplus, type:

    On Unix systems:

    @/home/yourhome/jps1.1/database.sql/oracle.sql
    On Windows systems:
    @C:\jps1.1\database.sql\oracle.sql