0

I have a GlassFish 4.0 server, and I've configured a MySQL connection pool and a resource name for the pool. I can access the pool using simple JDBC.

Now I want to use JPA, and this is where I'm lost.

I believe that Glassfish already includes EclipseLink, so if I want to use that, I do not need to configure anything. Is that correct?

However, I need to configure EclipseLink to use the pool resource. I assume this is done in an XML file somewhere, but I'm not sure which one and where it should be.

Finally, how do I access this from within my application? I assume I need to ask the container to @Inject something, but I'm not sure what.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Rick
  • 362
  • 5
  • 16
  • have a look at the Java EE tutorial. The page http://docs.oracle.com/javaee/6/tutorial/doc/bnbqw.html should answer all your questions. It's for EE6 but still valid in EE7. – Korgen Oct 25 '13 at 12:30

1 Answers1

0

I've spent one night to find the solution . After that I hated Glassfish and I am moving to the new WildFlyAS. Look if u use the GF installed with is Netbeans than put the driver of mysql in the C:\Program Files\glassfish-4.0\glassfish\lib. and if u use the other downloaded version zipped. u put the driver in this path D:\tools\glassfish4-install\glassfish\domains\domain1\lib\ext. I was working on netbeans and eclipse and I was comparing the two IDEs to choose wich one I will use in the near future with JEE7. So , whatever the IDE that u will use u need only to choose a good placement of mysql jar driver for the GF4! This still being amazing for me! and sure that will be for u ...just test it. Now lets talk about JPA ! this lines will explain it for you

        <jta-data-source>jdbc/cv</jta-data-source>
          <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/cv" />
        <property name="javax.persistence.jdbc.user" value="root" />
        <property name="javax.persistence.jdbc.password" value="" />
        <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />

you need the first line as I think. write your connection pool's name. & Good luck!