|
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 3 (10.1.3) B14428-01 |
|
![]() Previous |
![]() Next |
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".
Example 19-43 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 prefix.
Example 19-43 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".