persistence@glassfish.java.net

can I create an EntityManagerFactory in Java EE?

From: Decker, Paula \(EOIR\) <"Decker,>
Date: Fri, 13 Feb 2009 10:38:29 -0500

Hello,

 

Is it possible to change the database in Java EE based on values read in
from a config file? How can I create an EntityMangerFactory based on
the new database parameters?

 

I know this can be done in Java SE, by creating an EntityManagerFactory
with a map containing user, password, database url, and driver.

 

What about Java EE? I know the container is responsible for creating
the EntityManagerFactory based on the persistence.xml file it finds
packaged in the war file. Is it advisable to create a new
EntityManagerFactory in Java EE? Is it possible?

 

Thanks in advance.

 

PD