BC4J Hotel Reservation System Sample
Table Of Contents
Overview of the application
|
|
This sample illustrates
the implementation of a Hotel Reservation System(HRS) using Oracle
Business Components for Java (BC4J) Framework.
Oracle Business Components
for Java is a 100%-Java, XML-powered framework that enables productive
development, portable deployment and flexible customization of multi-tier
database intensive applications from reusable components.
This Hotel Reservation System
sample provides the following functionalities :
- Hotel Information Enquiry
like Room Rates, Room Types, Facilities available etc.
- Reservation and Cancellation
for Hotels
- Addition of new hotels
to the list of available hotels
- Hotel Information Modification
like modification of Room Rates, Room Types etc.

The software required for running the sample are :
- Oracle9i JDeveloper 9.0.3, dowloadable from here
- Oracle9i Database Release 9.0.2 or later, downloadable from
here
- Oracle9i Travel Schema, downloadable from here
This following notations are used through out this document
|
Notation
|
Description |
|
<J2EE_HOME>
|
Folder where J2EE setup is
installed. For example, D:\JDeveloper903\J2EE\HOME |
|
<SAMPLE_HOME>
|
Folder where
BC4JSample will be unzipped. For example,
C:\BC4JSample |
Extracting the source code
|
|
Execute the following command to extract the sample application
The above command extracts all the sample files to BC4JSample
folder. Click here to view the directory structure
and description of sample files.
Configuring the application
|
|
Preparing the Database
Ensure that 'Travel Schema' is loaded
into the database, see Required Software section
for more details.
Run SQL script fac.sql
available at <SAMPLE-HOME>\BC4JSample\database
directory using the following command at SQL prompt:
SQL>
connect travel/travel@<TNSName>
SQL>
@<SAMPLE-HOME>\BC4JSample\database\fac.sql
|
|
The SQL script ensures that existing data
in the travel schema such as PHONE, FAX and HotelURL in the HOTELS table
conforms to certain validation rules that are defined in this Sample.
Setup Connection Parameters
Edit config.properties file available
at <SAMPLE-HOME>\BC4JSample\config
directory. Change and save the following settings based on your system
configurations:
Database Specific Details
HostName |
Database Host Name |
PortNumber |
Database Port Number |
SID |
Database SID |
UserName |
Database User Name |
Password |
Database Password |
OC4J Specific Details
OC4JHostName |
OC4J Host Name |
OC4JUserName |
OC4J User Name |
OC4JPassword |
OC4J Password |
RMIPort |
RMI Port Number (by default 23791) |
InternalConnection |
Data source as given in the datasources.xml |
Deploying and running application with EJB
configuration to OC4J using Oracle9i
JDeveloper
|
|
This section describes the steps required
in deploying this application OC4J using Oracle9i JDeveloper
Step 1. Open <SAMPLE_HOME>\BC4JSample.jws
in Oracle9i JDeveloper.
The workspace contains two projects viz. BC4JHRS.jpr,
BC4JJavaClient.jpr.
Step 2. Create an Application Server Connection. From System Navigator,
Connection ->Application Server.
Right click on Application server, click on New
Connection. The Application Server Connection wizard starts. Provide
appropriate connection parameters of the Application server to which you
wish to deploy the EJBs.
NOTE: To test the application server connection, you need to start OC4J
server. Navigate to <J2EE_HOME>
and execute the following command:
Step 3. Create Database Connection
Object
i) From System Navigator, right click on
Connections->Database and select 'New
Connection.'. This starts a connection wizard.
Skip the welcome screen by clicking Next
button.
ii) Give the connection name as bc4jhrs,
click Next.
iii) Enter username and password
as Travel.
Select the Deploy Password option, click
Next.
iv) Enter the Hostname, Port and SID of
the database used, click Next.
v) Select the Finish button.
Step 4. Add entries in the datasources.xml
available at <J2EE-HOME>\config
copy the following XML tag to the file, just before the </data-sources>
tag
<data-source
class="com.evermind.sql.DriverManagerDataSource"
name="OracleDS"
location="jdbc/OracleCoreDS"
xa-location="jdbc/xa/OracleXADS"
ejb-location="jdbc/OracleDS"
connection-driver="oracle.jdbc.driver.OracleDriver"
username="travel"
password="travel"
url="jdbc:oracle:thin:@insn104a.idc.oracle.com:1521:ora9idb"
inactivity-timeout="30"
/>
Change the hostname , port and sid (highlighted in red
color) of the database in the copied XML tag and restart OC4J server.
Step 5. To deploy the Business components.
i) From System Navigator, expand BC4JHRSEjb.bcdeploy
-> BC4JHRSEJB.deploy node in BC4jHRS.jpr.
Ii) Right click BC4JHRSEJB.deploy
node. Select deploy to <Your-ApplicationServer-Connection>,
where <Your-ApplicationServer-Connection>
refers to the Application Server Connection you created in Step
2.
iii) View log window to check successful
deployment.
This completes the deployment of Oracle
Business components for Java (BC4J) to OC4J.
EJB Configuration :
In this configuration, the Application
Module is deployed to OC4J as EJB Session Bean. For running the Java Client,
in this configuration, you must first deploy the Application Module to
OC4J as EJB Session Bean.
Step 1. From System Navigator, select and right click on
BC4JHRS.jpr. Select option Make BC4JHRS.jpr
to compile and build the project.
Step 2. Select and right click on BC4JJavaClient.jpr.
Select Project Settings -> Configurations
-> Development -> Runner, set the value for Program
Arguments as 'EJB' . Click OK
button.
Step 3. Right click on BC4JJavaClient.jpr,
select and click Run BC4JJavaClient.jpr to
run the Java client.
Running the application with LOCAL Configuration
using Oracle9i JDeveloper
|
|
NOTE: Using Local Configuration the deploying of BC4J components
is not required.
LOCAL Configuration
In this configuration, the Application Module is LOCAL to the Java Client
i.e. the application module and the client execute in the same JVM as
that of the client.
Step 1. From System Navigator, select and right click on
BC4JHRS.jpr. Select option Make BC4JHRS.jpr
to compile and build the project.
Step 2. Select and right click on BC4JJavaClient.jpr.
Select Project Settings -> Configurations
-> Development -> Runner, set the value for Program
Arguments as 'LOCAL' . Click
OK button.
Step 3. Right click on BC4JJavaClient.jpr,
select and click Run BC4JJavaClient.jpr to
run the Java client.
Description of sample files
|
|
Directory |
Filename |
Description |
BC4JSample\docs |
Readme.html |
This file. It contains description about
the sample and steps to deploy and run the sample. |
blaf.css |
Cascading stylesheet applied to Readme.html |
imageFBO.JPG |
Image containing UML model for the sample |
BC4JSample\src |
Bc4jhrs |
This package contains Oracle
Business Components for Java (BC4J) |
BC4JSample\src\BC4JJavaClient |
BC4JHotelFrame.java |
This Java file contains the GUI portion
of the HRS application |
BC4JHotelSample.java |
This Java file contains the logic to
access the HotelSystem EJB and forms the main class of the client
JAR file. |
GenTableModel.java |
This Java file contains methods which
maintains the data required for a JTable handling |
BC4JJavaClient.jpr |
JDeveloper project file |
logo.gif |
HRS logo image |
BC4JHRS.jws |
JDeveloper workspace file |
BC4JSample\ |
BC4JHRS.jpr |
JDeveloper project file. |
BC4JHRSEjb.bcdeploy,
BC4JHRSCommon.deploy,
BC4JHRSMiddleTier.deploy,
BC4JHRSEJB.deploy |
Deployment profile files for BC4J components |
BC4JSample\src\META-INF |
orion-ejb-jar.xml |
Contains EJB information |
ejb-jar.xml |
This file is used to define the Web application
deployment parameters and is included in the WAR file. |
BC4JSample\database |
fac.sql |
SQL script to update Travel Schema |
BC4JSample\config |
config.properties |
Contains JNDI configuration parameters. |
Please enter your comments about this sample in the OTN
Sample Code Discussion Forum.
|