File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

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 .

Thanks,
smita
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' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>statelessSession</ejb-name>
<home> myapp.MYAPPWebServiceHome</home>
<remote> myapp.MYAPPWebService</remote>
<ejb-class> myapp.MYAPPWebServiceBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>statelessSession</ejb-name>
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
<container-transaction>
</assembly-descriptor>
</ejb-jar>
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' 'http://www.bea.com/servers/wls510/dtd/weblogic-ejb-jar.dtd'>
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>statelessSession</ejb-name>
<caching-descriptor>
<max-beans-in-free-pool>100</max-beans-in-free-pool>
</caching-descriptor>
<jndi-name>stateless.MYAPPWebServiceHome</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>

Following is my code in the ejb method:
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,
"t3://hostName:7001");
// 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();
Thanks,
smita
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using connection pool in EJb
 
Similar Threads
Deployment
Front Controller pattern and DataSource / Connection sharing
enterprise application with many users
why data source?
Pool