0

Generally speaking, how is a persistence.xml in a library configured to use JDBC Connection Pooling with EclipseLink and JPA?

When the library is used by the web module of an Enterprise Application, the library's configuration file is organized to reference the JDBC Resource on Glassfish through a JNDI lookup?

Specifically, how is this persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="EJBRemoteInterfacePU" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>dur.jpa.Client</class>
    <properties>
      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/legacy?zeroDateTimeBehavior=convertToNull"/>
      <property name="javax.persistence.jdbc.password" value="password"/>
      <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
      <property name="javax.persistence.jdbc.user" value="jdbc"/>
    </properties>
  </persistence-unit>
</persistence>

changed to utilize the jdbc/legacy_resource below:

asadmin> 
asadmin> list-jdbc-resources
jdbc/sample
jdbc/__TimerPool
jdbc/__default
jdbc/local
jdbc/legacy_resource
Command list-jdbc-resources executed successfully.
asadmin> 
asadmin> list-jdbc-connection-pools
CLI031: Warning: Option "target" is obsolete and will be ignored.
CLI031: Warning: Option "target" is obsolete and will be ignored.
__TimerPool
DerbyPool
SamplePool
connectionPool
legacy_on_glassfish
Command list-jdbc-connection-pools executed successfully.
asadmin> 

see also:

http://wiki.eclipse.org/EclipseLink/Examples/JPA/GlassFishV2_Web_Tutorial

http://javahowto.blogspot.ca/2011/02/sample-glassfish-resourcesxml.html

Thufir
  • 8,216
  • 28
  • 125
  • 273
  • I don't understand the question. What you have defined in the persistence.xml is JDBC connection details the provider is to use directly. What you are using is RESOURCE_LOCAL and generally used outside of EJB containers where there are no datasources provided. If you look at the link you provided, http://wiki.eclipse.org/EclipseLink/Examples/JPA/GlassFishV2_Web_Tutorial#Persistence.xml the persistence xml shows data-source tags that tell it which datasource to look up from glassfish. – Chris Oct 28 '14 at 17:38
  • @Chris the `` tag should match the jdbc resource in glassfish? – Thufir Oct 29 '14 at 10:34

0 Answers0