• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Modify persistence.xml file runtime

 
Mahesh Kedari
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Is is possible to modify persistence.xml file runtime? The question is because, i am accepting database details from user and accordingly i wanted to change my connection settings to database. Table structure in new database will be exactly same but database name, user id, password or may be database type (MySQL, Oracle, MSSQL) can be different.

Now if i am using persistence.xml file, im restricted (dont know if there is any alternative) to define database name, user name and password before i run my code.
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can pass a Map of properties when creating an EntityManagerFactory (or EntityManager). Your provider should allow overriding of connection properties in the properties Map.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic