Locating a database at runtime
I have written a java application using Netbeans (and I'm also asking this question on the Netbeans mailing list...) The program uses a MySQL database and Hibernate. When I wrote the program, I configured it to find the database on 'localhost'. And it works fine. But now I am ready to deploy the application. In one instance the database really is on the same machine, and that works. But on a second machine, the database is located remotely. Can someone tell me how I can reconfigure the database connection on the fly? I can pass the host name or IP address in on the command line, but I'm not sure what to do with it when I get it. The information appears to be stored in the 'persistence.xml' file that Netbeans creates. For any instance of my program, once it connects, it will not have to be changed...
Much obliged,
nbc
|