Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Reusing an Existing Datasource?

Here's a code snippet for using a Derby DataSource.  There's no connection info in the persistence.xml in this sample.


    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();
        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.


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.


eclipselink-users mailing list


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