Menu

Create a Connection Identifier

Ralph

A connection identifier is used to create a connection to the database.
EclipseLink uses the file META-INF/persistence.xml as usual in JPA to setup the connection properties.

Create a file persistence.xml in folder META-INF of your project:

<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
    <persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
        <class>de.hoppe.extra.model.Person</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
        <properties>
            <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver" />
            <!-- EclipseLink should NOT create the database schema -->
            <property name="eclipselink.ddl-generation" value="none" />
            <property name="eclipselink.target-database" value="Auto" />
            <property name="eclipselink.target-server" value="none" />
        </properties>

    </persistence-unit>
</persistence> 

The JDBC driver is from Oracle. Please use the appropriate JDBC driver for MySQL, HSQL, Progress or the database you are using.
This file names only the class de.hoppe.extra.model.Person under control of EclipseLink.
Do not forget to add additional classes if needed.


Next step is to [Create an Entity].


Related

Wiki: Create an Entity
Wiki: How to start

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.