Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g (

Part Number E13981-01
Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Index
Go to Feedback page
Contact Us

Go to previous page
Go to next page
View PDF

Looking Up an EJB 2.1 Resource Manager Connection Factory

Using EJB 2.1, you can look up a resource manager connection factory using the InitialContext (see "Using Initial Context").

For more information on configuring resources, see "Resource Manager Connection Factory Environment References".

Using Initial Context

Example 19-30 shows how to look up a JDBC data source resource manager connection factory within the bean's code using the InitialContext with the logical name defined in the EJB deployment descriptor (see "Configuring an Environment Reference to a JDBC Data Source Resource Manager Connection Factory") prefixed with java:comp/env/jdbc.

Example 19-30 Looking Up a JDBC Data Source Resource Manager Connection Factory

javax.sql.DataSource db;
java.sql.Connection conn;
InitialContext ic = new InitialContext();
db = (javax.sql.DataSource) initCtx.lookup("java:comp/env/jdbc/OrderDB");
conn = db.getConnection();

For more information, see "Configuring the Initial Context Factory".