Oracle9i Database
version 9.2 or above downloadable from OTN.
OC4J (Oracle9iAS
containers for J2EE) Release 9.0.3 Production downloadable from
OTN.
JDK(Java Developer's Kit) version 1.3 or higher
downloadable from http://java.sun.com(or) Oracle9i JDeveloper
version 9.0.3 downloadable from OTN
.
Oracle XDK(XML Developer's Kit) for java downloadable
from OTN.
ANT tool for building the Enterprise ARchive (EAR)
file which can be downloaded from Jakarta Apache.
Any JavaScript and XML enabled browser.
Note: => This sample has been certified with Red
Hat Linux Advanced Server 2.1, Solaris 5.6 and Windows
NT 4.0, Windows 2000.
=> Best
viewed with browsers Netscape Navigator 6 or above, Microsoft
Internet Explorer 5 or above. On Linux, best viewed with the Mozilla
1.3 or above browser.
The application files are stored in
an archive named ProductOrder.jar. Download the
archive and extract it to a convenient directory. Execute following command
to extractthe files:
jar xvf ProductOrder.jar
The archive ProductOrder.jar
extracts the files that implement the Product Order System. All the files are
extracted into the "ProductOrder" directory.
To create the Product Order schema follow the steps below :
In Sql*Plus, Login to your Oracle9i
Database using a user with sysdba privilege. For ex:
sqlplus> connect sys/change_on_install@db_alias
as sysdba;
Now, create a new user with the required privileges using the
following commands in Sql*Plus :
sqlplus> CREATE USER orderuser IDENTIFIED
BY orderuser;
sqlplus> GRANT connect,resource TO orderuser;
Then, login as the user created above from Sql*Plus and run the
script CreateTables.sql under
the ProductOrder/sql directory extracted
above. For example :
This script will create all the tables, constraints, sequence
and triggers required for the application.
Setting up JDK Environmental Variables
Note:
=> This application has been certified for Korn Shell
in Solaris and Linux. All the instructions for Solaris
and Linux pertains to the Korn shell in it. You can enter into Korn
Shell in Solaris and Linux by typing "ksh" on
the command prompt.
=> Setting the environmental variables is not required
when you are compiling java files with Oracle 9i JDeveloper.
Set the JAVA_HOME environment variable.
Eg. For Windows - set JAVA_HOME=<JAVA_HOME>
Eg. For Solaris and Linux - export JAVA_HOME=/usr/java1.3
Set the PATH environmental variable
Eg. For Windows - set PATH=%JAVA_HOME%\bin;%XDK_HOME%/bin
Eg. For Solaris and Linux - export PATH=$JAVA_HOME/bin:$XDK_HOME/bin:
Add ANT to the PATH only for EAR deployment
Eg. For Windows - set PATH=%JAVA_HOME%\bin;%XDK_HOME%/bin;%ANT_HOME%/bin
Eg. For Solaris and Linux - export PATH=$JAVA_HOME/bin:$XDK_HOME/bin:
$ANT_HOME/bin
Set the CLASSPATH environmental variable. Make sure that classpath
visits following jars.
These files are part of XDK and OC4J.
XDK_HOME\lib\xmlparserv2.jar
XDK_HOME\lib\xschema.jar
XDK_HOME\lib\xsu12.jar
XDK_HOME\lib\classgen.jar
XDK_HOME\lib\oraclexsql.jar
OC4J_HOME\j2ee\home\oc4j.jar
OC4J_HOME\j2ee\home\lib\servlet.jar
Note : In addition to the above jar files, add the current
directory to the CLASSPATH environment variable.
Eg. For Windows - set CLASSPATH=%CLASSPATH%; %XDK_HOME%\lib\oraclexsql.jar;
%XDK_HOME%\lib\xmlparserv2.jar;%XDK_HOME%\lib\ xschema.jar;
%XDK_HOME%\lib\classgen.jar;%OC4J_HOME%\j2ee\home\oc4j.jar;%OC4J_HOME%\j2ee\home\lib\servlet.jar;.
Eg. For Solaris and Linux - export CLASSPATH=$CLASSPATH:$XDK_HOME/lib/oraclexsql.jar:$XDK_HOME/lib/xmlparserv2.jar:
$XDK_HOME/lib/xschema.jar:$XDK_HOME/lib/classgen.jar:$OC4J_HOME/j2ee/home/oc4j.jar:
$OC4J_HOME/j2ee/home/lib/servlet.jar:.
Setting up OC4J for XML9i
Class Generator and XSQL pages
Copy the classgen.jar from the XDK_HOME\lib
directory to the OC4J_HOME\j2ee\home\lib directory.
Copy the oraclexsql.jar, xmlparserv2.jar,
xschema.jar and xsu12.jar archives from
the XDK_HOME\lib
directory to the OC4J_HOME\j2ee\home\lib directory.
Copy the XSQLConfig.xml file in the XDK_HOME\xdk\admin
directory to the OC4J_HOME\j2ee\home\lib directory.
Setting up the database connection for XSQL Pages : To setup the
database connection,
a) Edit the XSQLConfig.xml file
in the j2ee\home\lib directory and add the following connection
information within the <connectiondefs>...</connectiondefs>
tags :
<connection name="otn9i">
<username>orderuser</username>
<password>orderuser</password>
<dburl>jdbc:oracle:thin:@hostname:port:sid</dburl>
<driver>oracle.jdbc.driver.OracleDriver</driver>
</connection>
where,
username - is the name
of the database user created above i.e orderuser
password - is the password of the orderuser
user i.e orderuser
hostname - is the hostname of the machine
where Oracle9i database is running.
port - is the port on the hostname
where the database listener is listening to.
sid - is the sid of your database. Note: Do not change the connection name 'otn9i'
used above since all the XSQL pages use this to
make the database connection.
b) Make sure that in the same XSQLConfig.xml
file edited in step a, the value for the <factory> tag inside
<connection-manager>...</connection-manager> tags is
set to the default
value i.e oracle.xml.xsql.XSQLConnectionManagerFactoryImpl.
Go to OC4J_HOME\j2ee\home\config
directory.
Add the following entries to global-web-application.xml
to recognize the .xsql pages under
<web-app>...</web-app> tags.
The 'ORACG' command line utility of Oracle9i XDK is used to generate
java classes as below.
Make sure that you have XDK_HOME/bin is in your PATH.
Go to ProductOrder/xml directory.
At the command prompt do the following: java oracle.xml.classgen.oracg -comment -schema
ProductOrder.xsd -package oracle.otnsamples.ProductOrder
This will create .java files for the ProductOrder.xsd
under ProductOrder/xml inside the directory
"oracle".
The .java files created will be: Customer.java, Products.java, ProductOrder.java.
Note: You can compile the source code with either JDK 1.3 or
Oracle9i JDeveloper.
Compiling the sources with
Oracle9i JDeveloper
Copy the oracle directory created by
ORACG which is in ProductOrder/Xml directory
to ProductOrder/java directory..
Open Oracle9i JDeveloper.
Go to ProductOrder directory which got
created while extracting the jar and open ProductOrder.jws
Expand ProductOrder.jws node by clicking it.
Expand ProductOrder.jpr node by clicking it. You can view entire
source for OrderXmlBean.java, PoInsertHandler.java, ProductOrder.java,
Customer.java and Products.java.
Right click ProductOrder.jpr
Select Project Settings from pop up menu
In the node Common -> Input Paths, edit java source path and ensure
that java directory is part of the path where the source
files are found.
Expand Configurations node from left hand panel.
Expand Development node
Click on Libraries node in left panel
In the available libraries box in the left hand panel click on Oracle
XML parser v2 and click on single right
handed arrow in the middle. This will add the library in current project.
Similarly, select Servlet Runtime, XSQL Runtime to add them to current
project.
Next, click on New button in this dialog box
New library dialog pops up
Enter library name as mypo
Click on Edit button for CLASSPATH entry.
In the Edit Class Path windowclick Add Entry button
Here, in the available libraries box in the right hand panel click
on mypo and click on single right handed arrow in the middle.
This will add the library in current project. Then, click OK for all
other open windows .
Compile all the files .
Oracle9i JDeveloper creates a classes directory inside ProductOrder
directory where we can find compiled class files.
Compiling the Java Sources
with JDK 1.3
Note: This application has been certified for Korn Shell in
Solaris and Linux. All the instructions for Solaris and Linux pertains to
the Korn shell in it. You can enter into Korn Shell in Solaris and Linux by
typing "ksh" on the command prompt.
Following steps need to be followed if we are compiling
the java sources using jdk:
Go to the ProductOrder/java directory where we have extracted
the java sources.
The directory contains two java files i.e OrderXmlBean.java
and PoInsertHandler.java.
Copy the oracle directory created by
ORACG which is in ProductOrder/Xml directory to ProductOrder/java
directory.
Compile all the files using the command. javac -d . *.java
Copying and Running the application
to OC4J
Copy the “ProductOrder” directory extracted to the OC4J_HOME\j2ee\home\default-web-app\examples\jsp
directory of your OC4J installation.
Go to OC4J_HOME\j2ee\home\default-web-app\WEB-INF\classes
directory.
Create drill-down directory structure as below:
oracle->otnsamples->ProductOrder
Copy all .class EXCEPT PoInsertHandler.class
to ProductOrder directory created above.
Go to OC4J_HOME\j2ee\home\lib directory.
Create drill-down directory structure as below:oracle->otnsamples->ProductOrder->xml->xsql->actions
Copy PoInsertHandler.class to actions directory
created above.
Restart the oc4j server.
Access the main page of the application using the URL :
where,
<oc4jserver> - is the hostname / ip-address of the machine
where OC4J is installed.
<port-no> - is the port number on which oc4j server is listening.
Default port is 8888.
Note:
=> Ensure that you have downloaded and installed “ANT”
tool (refer required software).
=> Ensure that you have JDK 1.3 or higher installed as it is required
for compilation of the .java sources which builds the EAR file
=> ANT_HOME\bin is in the PATH.
Go to ProductOrder/xml directory where
you have extracted the sample.
Move the oracle directory to ProductOrder/java
directory. Make sure that ProductOrder/xml
does not have oracle directory.
Delete all .class files if you have them when doing the
simple deployment.
Go to the root ProductOrder directory and type ant.
ANT generates ProductOrder.ear file and places it under
“build” directory.
where,
<oc4jserver> - is the hostname / ip-address of the machine where
OC4J is installed.
<port-no> - is the port number on which oc4j server is listening.
Default port is 8888.