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

  1. Download the zip and expand it in a directory of your choice.
  2. 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:
  3. %make   // If you have a makefile for the demo
  4. %ant      // ant if you have build.xml in your demo
  5. 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.
  6. Additional instructions for individual demos will be in their respective readme files.

Samples

  1. EJB performing JDBC operations
  2. EJB performing SQLJ operations
  3. Servlet calling EJB
  4. EJB calling EJB *
  5. Stateless Session Bean *
  6. Entity Bean with Bean-Managed Persistence
  7. Entity Bean with Container Managed Persistence
  8. OR Mapping for Container Managed Persistence
  9. Session Bean Managed Transaction
  10. Entity Bean with Container Managed Transaction
  11. 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'
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