Java Cookbook : Transaction Sample Java Cookbook : Transaction Sample


Table of Contents

Software Requirements
Terminology
Extracting the source code
Configuring the Application
Deploying and Running the Application
Sample Application Files

Software Requirements

List the softwares required for configuring and running this sample application.

Terminology

Term Definition
Folder where OC4J is installed. For example, in Windows it is D:\oc4j and in Linux it is /home/oc4j.

J2EE Home Folder which is part of OC4J installation. For example, in Windows it is D:\oc4j\j2ee\home and in Linux it is /home/oc4j/j2ee/home.

Folder where the Hotel Servlet sample will be unzipped. For example,in Windows it is C:\OTNSamples and in Linux it is /home/OTNSamples.
Folder where Java is installed. For example, in Windows it is C:\jdk1.3 and in Linux it is /usr/jdk1.3.
Folder where the ANT is installed. For example, in Windows it is C:\ant and in Linux it is /home/ant.


Extracting the source code

Execute the following command to extract the sample application. In windows environment, this file can also be opened using Winzip utility.
> jar -xvf TransactionSample.jar

The above command extracts all the sample files to TransactionSample folder. Click here to view the directory structure and description of sample files.


Configuring the Application

Preparing the Database:

This sample application uses two schemas namely Travel and Car_Dealer .
1. Ensure that 'Travel Schema' is loaded into the database. For more details about loading the Travel Schema Click here.
2. For installing Car_Dealer schema follow the steps below:

  • Connect to the database as SYSTEM user. Default password for SYSTEM user is MANAGER
  • Run the install.sql script file located in <SAMPLE_HOME>/TransactionSample/database directory

This creates a schema named car_dealer\car_dealer and populates it with the tables required by application and the sample data.

Deploying and Running the Application

The application can be deployed and run in either of the following ways:

Deploying and Running the application using Oracle9i JDeveloper

This section describes the steps required for deploying and running this application using Oracle9i JDeveloper.

Step 1:. Open the <SAMPLE_HOME>/TransactionSample/TransactionSample.jws in Oracle9i JDeveloper. The workspace contains TransactionSample.jpr (project file), Servlet files and other files.

Step 2: Create Database Server Connection  for travel Schema

  1. Select Database Server under the Connections Node.
  2. Right click on Database Servers and select "New Connection".
  3. In Step 1 of the wizard, enter the Connection Name as 'Travel'.
  4. In Step 2 of the wizard, provide 'travel' as user name and password for the travel schema. (by default travel).
  5. In Step 3 of the wizard, provide the appropriate database connection information where travel schema is loaded. 
  6. In Step 4 of the wizard, test the connection and Select 'Finish' button 

Step 3: Create Database Server Connection  for Car Schema

  1. Select Database Server under the Connections Node.
  2. Right click on Database Servers and select "New Connection".
  3. In Step 1 of the wizard, enter the Connection Name as 'Car'.
  4. In Step 2 of the wizard, provide 'car_dealer' as user name and password for the car_dealer schema.
  5. In Step 3 of the wizard, provide the appropriate database connection information where car_dealer schema is loaded. 
  6. In Step 4 of the wizard, test the connection and Select 'Finish' button 

Step 4: Right click TransactionSample.jpr and select "Make TransactionSample.jpr". This compiles all the java classes in the project.

Step 5: Right click TransactionSample.jpr and select "Run TransactionSample.jpr". This opens up the browser and runs the HotelServlet.
 

Deploying and Running the application using ANT

This section describes the steps required in deploying this application to the Standalone OC4J using ANT Tool.

Step 1:  SET Environment Variables

  1. Open the Command Prompt and Go to the <SAMPLE_HOME>/TransactionSample directory
  2. Ensure that JAVA_HOME environment variable is pointing to your JDK installation directory
  3. Ensure that <JAVA_HOME>/bin is in the PATH
  4. Ensure that <ANT_HOME>/bin is in the PATH

Step 2:  Modify the host name, database listening port and database sid attributes of <SAMPLE_HOME>/TransactionSample/config/data-sources.xml according to your own database settings.

Step 3:  Build the EAR file

From <SAMPLE_HOME>/TransactionSample, execute ant 

<SAMPLE_HOME>/TransactionSample > ant 

This will create the TransactionSample.ear file.

Step 4:
Ensure that OC4J is up and running.  To start the OC4J server, navigate to <J2EE_HOME> and execute the following command. 

java -jar oc4j.jar
 

Step 4: Having created a TransactionSample.ear file, to deploy this application to Standalone OC4J use the following command, from
<SAMPLE_HOME>/TransactionSample
directory.
 
> java -jar <OC4J_HOME>/j2ee/home/admin.jar ormi://localhost:23791 admin <oc4j password> -deploy -file <SAMPLE_HOME>/TransactionSample/build/TransactionSample.ear -deploymentName TransactionSample
Example:

On Windows,
> java -jar D:\oc4j\j2ee\home\admin.jar ormi://localhost:23791 admin welcome -deploy -file C:\OTNSamples\TransactionSample\build\TransactionSample.ear -deploymentName TransactionSample
On Linux,
> java -jar /home/oc4j/j2ee/home/admin.jar ormi://localhost:23791 admin welcome -deploy -file /home/OTNSamples/TransactionSample/build/TransactionSample.ear -deploymentName TransactionSample

Step 5:  Now, bind the web application using the following command.
 
> java -jar <OC4J_HOME>/j2ee/home/admin.jar ormi://localhost:23791 admin <oc4j password> -bindWebApp TransactionSample TransactionSample-web http-web-site /TransactionSample
Example:

On Windows,
> java -jar D:\oc4j\j2ee\home\admin.jar ormi://localhost:23791 admin welcome -bindWebApp TransactionSample TransactionSample-web http-web-site /TransactionSample
On Linux,
> java -jar /home/oc4j/j2ee/home/admin.jar ormi://localhost:23791 admin welcome -bindWebApp TransactionSample TransactionSample-web http-web-site /TransactionSample

Now, the application is deployed to the Standalone OC4J. 

Step 6:  Open your favorite browser and access the sample, using the following url.

http://<host_name>:<port>/TransactionSample/TransactionSample

where, <host_name> is the machine on which OC4J is running and <port> is Port to which the OC4J server listens to HTTP requests. By default OC4J listens for HTTP requests in port # 8888. 

For example,

http://demo.oracle.com:8888/TransactionSample/TransactionSample


Sample Application Files 

The sample is provided as a jar file TransactionSample.jar that contains the following files required for the sample. They get extracted in TransactionSample directory.

Directory File Description
build.xml Ant build script
Readme.html This file
TransactionSample.jws Oracle9i JDeveloper works space file
TransactionSample.jpr Oracle9i JDeveloper project file
application.xml This file is used to define the J2EE EAR file, which contains the location of EJB JAR file, Web application WAR file and is included in the EAR file
data-sources.xml This file contains application specifc datasource definition. This is included in the EAR file
orion-application.xml

This file used ot define orion specific configuration settings. This file contains reference to application specific data-sources.xml. This is included in the EAR file

ejb-jar.xml This file is used to define the EJB deployment
descriptors and is included in the EJB JAR file 
orion-ejb-jar.xml This file is used to define the orion specific EJB deployment
descriptors and is included in the EJB JAR file.
HotelDetails.java This file is used to define the information about a particular hotel.
RoomType.java This files is used to define the information about a particular room type
ReservationDetails.java This file contains information about a particular reservation made
HotelSummary.java This file contains information about all the hotels
HotelInformation.java This java file is the remote interface for the HotelInformation EJB
HotelInformationBean.java This java file contains the implementation of the methods declared in HotelInformation interface
HotelInformationHome.java This java file is the Home interface of the HotelInformation EJB
ReservationAgent.java This java file is the remote interface for the  ReservationAgent EJB
ReservationAgentBean.java This java file contains the implementation of the methods declared in ReservationAgent interface
ReservationAgentHome.java This java file is the Home interface of the ReservationAgent EJB
Hotel.java This java file is the remote interface for the Hotel EJB
HotelBean.java This java file contains the implementation of the methods declared by Hotel interface 
HotelHome.java This java file defines the Home interface of the HotelBean EJB
HotelPK.java This java file defines the Primary key of the Hotel EJB.
CarBooking.java This java file is the remote interface for the CarBooking EJB
CarBookingBean.java This java file contains the implementation of the methods declared by CarBooking interface 
CarBookingHome.java This java file defines the Home interface of the CarBooking EJB
HotelBooking.java This java file is the remote interface for the HotelBooking EJB
HotelBookingBean.java This java file contains the implementation of the methods declared by HotelBooking
HotelBookingHome.java This java file defines the Home interface of the HotelBooking EJB
HotelBookingPK.java This java file defines the primary key of the HotelBooking EJB
EJBHotelServlet.java This java file is the servlet client for the HRS application and contains methods which contains calls to the HotelInformation EJB & ReservationAgent EJB
EJBHotelServletHTML.java This java file has all the method's for generating the HTML text for display on the browser
logo.gif HRS logo image
Calendar Calendar image
web.xml This file is used to define the Web deployment descriptors and is included in the WAR file
Calendar.txt Calendar java script file
install.sql SQL file required for creating car_dealer schema.


Please enter your comments about this sample application here.

 

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