Oracle9iAS
Containers for J2EE - Code Samples
Oracle9i Application Server (Oracle9iAS) provides Oracle9iAS
Containers for J2EE (OC4J), a fast, lightweight, highly scalable, and easy-to-use
J2EE environment.
OC4J is written entirely in Java and executes on the standard Java Development
Kit (JDK) virtual machine. It provides a complete J2EE environment that includes
a JSP Translator, a Java Servlet engine and an Enterprise Java Beans (EJB)
container.
Check out the code samples below that demonstrate
some of the cool OC4J features and provide a great place to start for new J2EE
programmers. Additional samples will be added on an ongoing basis - so don't
forget to bookmark this page and visit frequently!
These applications come with their own Makefiles
or ANT files, which will compile, deploy, and run these applications.
Steps
- Download the zip and expand it in a directory
of your choice.
- In the expanded structure look for the Makefile
or the build.xml (ANT) file.Change directory to that of your makefile or ant
file. At the prompt type:
- %make // If you have a makefile
for the demo
- %ant // ant if
you have build.xml in your demo
- If you do not have gmake download it from the
GNU web site.
The path must contain ANT from Apache
to run examples built with ANT.
- Additional instructions for individual demos
will be in their respective readme files.
Samples
- EJB performing JDBC operations
- EJB performing SQLJ operations
- Servlet calling EJB
- EJB calling EJB *
- Stateless Session Bean *
- Entity Bean with Bean-Managed
Persistence
- Entity Bean with Container Managed
Persistence
- OR Mapping for Container Managed
Persistence
- Session Bean Managed Transaction
- Entity Bean with Container Managed
Transaction
- Message Driven Beans *
Note: * indicates new sample code
| # |
Description |
Download |
| 1 |
JDBC |
Note: Netscape
users, right-click and 'save as' |
| |
This sample demonstrates how to
lookup a datasource from an EJB and perform a simple select on the EMP tables
in scott. For this sample to run the user should make sure that classes12.zip
is in $OC4J_HOME/lib |
jdbcdemo.jar |
| 2 |
SQLJ |
|
| |
This sample accomplishes the same
thing as the JDBC sample but it uses SQLJ. For this sample to run the user
should ensure that translator.zip and runtime12.zip are in $OC4J_HOME/lib. |
sqljdemo.jar |
| 3 |
Servlet
Calling EJB |
|
| |
This sample demonstrates a servlet
calling an EJB. |
servlet2ejb.jar |
| 4 |
EJB
Calling EJB |
|
| |
This sample demonstrates an EJB
that performs lookup to locate another EJB and then invokes methods on it. |
ejb2ejb.jar |
| 5 |
Stateless
Session Bean |
|
| |
This
sample demonstrates a simple stateless session bean using the Emp table
in SCOTT schema.
|
stateless.jar
|
| 6 |
Bean
Managed Persistence |
|
| |
This sample demonstrates Bean
Managed Persistence and allows the user to add, delete and list all
the beans. In this sample a servlet, a JSP and an application client do
the same thing |
bmpdemo.jar |
| 7 |
Container
Managed Persistence |
|
| |
This sample demonstates container
managed persistence and performs the same tasks as the bean managed persistence
sample, only difference being that it uses container manage |
cmpdemo.jar |
| 8 |
OR-MapDemo |
|
| |
This sample is an advanced example
of object-relational mappings. it has two entity beans DeptBean and EmpBean
persisted to scott's dept and emp tables respectively:
-DeptBean has a Collection of Employees which map 1:n relationship [dept]---o<[emp]
(each deptartment may have one or more employees)
-EmpBean belongs to a Dept. maps 1:1 reverse relationship [emp]---o[dept]
(each employee may have one department) |
ormapdemo.jar |
| 9 |
Bean
Managed Transaction |
|
| |
This sample demonstrates Bean
Managed transactions using a session bean. |
bmtxn.jar |
| 10 |
Container
Managed Transaction |
|
| |
This sample demonstrates Container
Managed transactions. |
cmtxn.jar |
| 11 |
Message
Driven Beans |
|
| |
This
sample demonstrates the use of message driven beans in OC4J. |
messagelogger.ear
|
| |
|
Note:
Netscape users, right-click and 'save as' |
|