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.
Mahesh Kedari - Fidus Technologies Ltd.
posted 6 years ago
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.