File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes BEA/Weblogic and the fly likes using connection pool in EJb Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "using connection pool in EJb" Watch "using connection pool in EJb" New topic

using connection pool in EJb

peter brews
Ranch Hand

Joined: Jan 25, 2002
Posts: 59
Could you please post some sample code on how to use connection pool created in 6.1 in EJB .

Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
You should first wrap your Connection Pool with a Datasource.
Check the WebLogic Documentation for how to use a datasource.
peter brews
Ranch Hand

Joined: Jan 25, 2002
Posts: 59
Thanks for all your help.
Could you please suggest me where to specify this datasource in ejb-jar.xml & jndi name with datasource in ejb-weblogic-jar.xml
Following is my ejb-jar.xml:
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN' ''>
<home> myapp.MYAPPWebServiceHome</home>
<remote> myapp.MYAPPWebService</remote>
<ejb-class> myapp.MYAPPWebServiceBean</ejb-class>
following is my ejb-weblogic-jar.xml :
<?xml version="1.0"?>
<!DOCTYPE weblogic-ejb-jar PUBLIC '-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB//EN' ''>

Following is my code in the ejb method:
Hashtable ht = new Hashtable();
// Get a context for the JNDI look up
ctx = new InitialContext(ht);
javax.sql.DataSource ds
= (javax.sql.DataSource) ctx.lookup ("mydataSource-OracleThinDriverPool");
conn = ds.getConnection();
I agree. Here's the link:
subject: using connection pool in EJb
jQuery in Action, 3rd edition