Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Defining persistence.xml programatically?

Hi Tim,

   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");
Persistence.createEntityManagerFactory("unit-name", properties);

      Shaun

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?

  

--


Oracle
Shaun Smith | Principal Product Manager, TopLink | +1.905.502.3094
Oracle Fusion Middleware
110 Matheson Boulevard West, Suite 100
Mississauga, Ontario, Canada L5R 3P4

Back to the top