File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Entity Bean and mulitple datasource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Entity Bean and mulitple datasource" Watch "Entity Bean and mulitple datasource" New topic
Author

Entity Bean and mulitple datasource

Pinal N Patel
Ranch Hand

Joined: Sep 05, 2003
Posts: 57
Hello,
Is it possible to have multiple entity beans connecting to multiple datasources in one container?. If yes, Is it by listing the datasource name in bean specific JNDI ENC?
For eg: In one container,
Bean1 connects to DataSource1
Bean2 connects to DataSource2
I appreciate your help in advance.
Regards,
Pinal
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Yes, it is possible. Let's say you have a bean implementation called MyEntityBean. You would need to
1) Deploy one EJB with MyEntityBean as the implementation having a resource reference to "DataSource1" in its ejb-jar.xml configs
2) Deploy another EJB with the same implementation class but having a resource reference in ejb-jar.xml pointing to "DataSource2"


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Naveen Sharma
Ranch Hand

Joined: Mar 23, 2001
Posts: 65
can't we have 2 datasources in one ejb-xml file..
in this way there is no need to put them into 2 jars

regards
Naveen
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

can't we have 2 datasources in one ejb-xml file..

Yes, you can.


Groovy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Entity Bean and mulitple datasource
 
Similar Threads
'single-threaded'ness of ejbs
Are Remote objects multithreaded?
how many entity bean objects are created
BMP Datasource connection problem
Container managed Entity Beans