i using JPA (JAVA, Eclipse) and want to change the Database dynamically. This should work with the following code i found out of an other topic:
(Changing Persistence Unit dynamically - JPA)
EntityManagerFactory managerFactory = null;
Map<String, String> persistenceMap = new HashMap<String, String>();
persistenceMap.put("javax.persistence.jdbc.url", "<url>");
persistenceMap.put("javax.persistence.jdbc.user", "<username>");
persistenceMap.put("javax.persistence.jdbc.password", "<password>");
persistenceMap.put("javax.persistence.jdbc.driver", "<driver>");
managerFactory = Persistence.createEntityManagerFactory("<currentpersistence unit>", persistenceMap);
manager = managerFactory.createEntityManager();
But sadly its not working for me. My problem is that the properties of the EntityManagerFactory stay empty (if i load them out of the xml they work perfectly fine and are not empty but if i load them with the other constructor call they are not set, i dont know why)
Here is a screenshot of the debugger: (i dont have enough reputation to post it, so here is the imgur link) https://i.stack.imgur.com/UBFOz.png
So for short, i call the Persistence.createEntityManagerFactory("", persistenceMap) Methode but it does not change the properties of the Manager and i cant connect to my database because no properties are set.
Any idea why its not working?
Thank you for your help and your time.
This is my first post and after a long search on the web i descided to give it a try and post my problem.
Michael