Here's a code snippet for using a Derby DataSource. There's no
connection info in the persistence.xml in this sample.
--Shaun
private DataSource createDataSource() {
/**
* <property name="eclipselink.jdbc.url"
value="jdbc:derby://localhost:1527/sample;create=true"/>
* <property name="eclipselink.jdbc.user" value="app"/>
* <property name="eclipselink.jdbc.password"
value="app"/>
*/
ClientDataSource dataSource = new ClientDataSource();
dataSource.setServerName("localhost");
dataSource.setPortNumber(1527);
dataSource.setDatabaseName("sample");
dataSource.setUser("app");
dataSource.setPassword("app");
return dataSource;
}
private EntityManagerFactory getEntityManagerFactory() {
if (emf == null) {
Map<String, Object> properties = new
HashMap<String, Object>();
properties.put(PersistenceUnitProperties.NON_JTA_DATASOURCE,
createDataSource());
emf = Persistence.createEntityManagerFactory(PU_NAME,
properties);
}
return emf;
}
natjohns wrote:
I did
this, but I just used the Spring framework to set up JPA and my old
DAOs and datasources. You would just follow the examples on the Spring
website, or one of Shauwn's or Doug's Blogs had some good example too.
Nate
Tim Hollosy wrote:
I'm attempting to get EclipseLink to play
nice with an existing DAO
(J2SE project),
and I'd like to have reuse an existing JDBC Datasource rather than
configuring EclipseLink to connect itself. Is this possible? I don't
see anything obvious in the API.
Thanks!
--
./tch
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
--
Shaun Smith | Principal Product Manager, TopLink |
+1.905.502.3094
Oracle Fusion Middleware
110 Matheson Boulevard West, Suite 100
Mississauga, Ontario, Canada L5R 3P4
|