|Re: [eclipselink-users] Defining persistence.xml programatically?|
You can provide all the login info programatically when you create your EntityManagerFactory. You can see an example of this in a blog Doug did on overriding login info in the persistence.xml. http://java-persistence.blogspot.com/2008/02/testing-eclipselink-jpa-in-javase.html
Here's an abbreviated code sample from the blog:
import static org.eclipse.persistence.jpa.config.PersistenceUnitProperties.*; ... Map properties = new HashMap(); // Configure the internal EclipseLink connection pool properties.put(JDBC_DRIVER, "oracle.jdbc.OracleDriver"); properties.put(JDBC_URL, "jdbc:oracle:thin:@localhost:1521:ORCL"); properties.put(JDBC_USER, "user-name"); properties.put(JDBC_PASSWORD, "password");
Tim Hollosy wrote:
I'm looking into using EclipseLink in an RCP application, and for obvious reason's i'm not keen on distributing my database login info in an xml file. I'd like to define it programatically in java, however all the documentation I can find just talks about defining a project.xml or sessions.xml Has anyone done this?
Back to the top