I have a Swing-application connecting to a server using JPA. It happens that the server-hardware is changing and so the IP-address. What I want to do is to change the persistence.xml to point to the new server.
If the persistence.xml is inside the jar I am not able to change it without re-compiling and packaging the application. So the idea is to have persistence.xml outside the JAR-file and change it before starting up the application.
So my questions are:
1. Is it possible to have persistence.xml outside the JAR-file?
2. If yes how to make it available to the application?
3. If no, does anybody know how to accomplish the use case?
I thought this is a common use case, but searching the Internet didn't point to a solution.
So in the above persistence.xml version databaseserver:9002 is the database server accessible within the LAN. If I am traveling (with my notebook PC) and I want to access the database I have to change databaseserver:9002 to something like www.mydomain.com:9002. This I would like to do with starting up a preferences dialog where I can change the database server address without re-compiling and re-JARing.
Are you running the application standalone or are you running in an application server? For JBoss AS, I know that you can deploy an exploded jar (i.e. like a folder), so you don't have to unjar, edit and re-jar the application. In JBoss AS, you can even have the property value as a placeholder, for example:
and then pass the "DbServer" value as a Java system property: