This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Accessing multiple databases with JPA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Accessing multiple databases with JPA" Watch "Accessing multiple databases with JPA" New topic
Author

Accessing multiple databases with JPA

Saathvik Reddy
Ranch Hand

Joined: Jun 03, 2005
Posts: 228
Hi,

I am trying to access multiple databases from an enterprise application. How to configure the persistance unit if i have to access multiple databases.

Can i have multiple persistence units in the persistence.xml file.

Please suggest me on this.

Thanks,
Srikanth.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10069
    
163

Originally posted by Srikanth Reddy:
Hi,

I am trying to access multiple databases from an enterprise application. How to configure the persistance unit if i have to access multiple databases.


You can configure each persistence unit to use one database. So if you have multiple databases, you can configure the corresponding number of persistence units.

Originally posted by Srikanth Reddy:

Can i have multiple persistence units in the persistence.xml file.



As per the xsd http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd, yes you can have multiple persistence units in a single xml file.


[My Blog] [JavaRanch Journal]
Saathvik Reddy
Ranch Hand

Joined: Jun 03, 2005
Posts: 228
Thanks a lot.
 
Don't get me started about those stupid light bulbs.
 
subject: Accessing multiple databases with JPA