This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Is it possible to change the database in Java EE based on values read in from a config file by a web service deployed in an application server? 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?
How would this file's contents be affected by the creation of a new EntityManagerFactory at runtime? How do I associate the new jta-data-source with the new database properties? Should I use: new EntityManagerFactory("namePU", map), where map contains the properties from the above snippet?