EJB QL Sample Application

Table of Contents

Required Software

Back To Top
  • OC4J 9.0.4 or later (Developers Preview or Production) downloadable from here
  • Oracle9i Database or higher downloadable from here
  • Ant (Version 1.5 or higher) downloadable from here

Notations Used

Back To Top
Notation Description
<OC4J_HOME> Folder where OC4J is installed. For example, D:\oc4j
<SAMPLE_HOME> Folder where the EJB QL Sample Application is extracted. For example, D:\Ejbql

Extracting the source code

Back To Top

Use the following command to extract the source code.

  > jar xvf ejbqlsample.jar

Click here to view the directory structure and description of sample files. 


Configuring the application

Back To Top

1. Connect as any user to the database. Run the following command on the SQL Prompt :

  SQL> @<SAMPLE_HOME>/sql/Install.sql

This will create a table USERACCOUNT and a sequence AccountNumber_Seq.
2. Go to the directory <SAMPLE_HOME>/src/META-INF and edit the file data-sources.xml in your favorite XML editor.
Change the connection parameters to the values of the database where the Install SQL script was run :

<host_name>

This is the machine where the database has been installed

<port_no>

The is the port on which the database listens

<sid>

This is the SID of the database

<db_user>
This is the database user where the SQL script was run
<db_pwd>
This is the password of the user where the tables are created

Deploying and Running the application

Back To Top

1. Go to the directory <SAMPLE_HOME> on command prompt and type the following command

  > ant

The script will prompt for the value of <OC4J_HOME>. Provide the value of <OC4J_HOME> with full path (Ex : D:\oc4j).
This will create the ear file ejbql.ear under the folder <SAMPLE_HOME>/build. 
2.  Go to the directory <OC4J_HOME>/j2ee/home on command prompt and type the following :

  > java -jar oc4j.jar

This will start the OC4J server.
3. Now, we will deploy the sample application onto OC4J. Open another command prompt and go to the folder <OC4J_HOME>/j2ee/home and run the following commands one-by-one

  > java -jar admin.jar ormi://<machine_name>:<admin_port> admin <admin_pwd> -deploy -file <SAMPLE_HOME>/build/ejbql.ear -deploymentName Ejbql

  > java -jar admin.jar ormi://<machine_name>:<admin_port> admin <admin_pwd> -bindWebApp Ejbql ejbql-war http-web-site /ejbql


where,
<machine_name> Name of the machine where OC4J Server is running
<admin_port> Admin Port on which the OC4J server listens. This value by default is 23791 unless explicitly changed by the user
<admin_pwd> Adminstrator password to access OC4J. The default value is welcome
4. Now, open your favorite browser and access the following URL.

  http://<machine_name>:<oc4j_port>/ejbql/

where,

<machine_name> Name of the machine where OC4J Server is running
<oc4j_port> Port on which the OC4J server listens. This value by default is 8888 unless explicitly changed by the user

Now, go ahead, Create an Account and Search for it. Remember to select the appropriate radio button when querying different accounts.



E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy