• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

JPA Pro 2 chapter 3 employeeService  RSS feed

 
Ranch Hand
Posts: 1732
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I updated the original persistence.xml into:

These values are specified to mySQL and I have a database called myTest.

The original persistence.xml provided is:

This may not be applicable to those who don't use Derby database.
And also, the Employee.java should implement Serializable:


And you may want to follow my file structure in Eclispe. See the diagram below.

Create a folder META-INF  under src and put persistence.xml there.
Include eclispelink.jar, javax.persistence...java and mysql-connector-...java in the classpath.

I hope this help.
fileStructure.JPG
[Thumbnail for fileStructure.JPG]
 
Himai Minh
Ranch Hand
Posts: 1732
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more notes, the persistence.xml should be :

Reference:
http://www.javaxt.com/Tutorials/Glassfish/How_to_set_up_a_Connection_Pool
https://dzone.com/articles/connection-pooling-glassfish-nb
https://computingat40s.wordpress.com/how-to-setup-a-jdbc-connection-in-glassfish/
 
Himai Minh
Ranch Hand
Posts: 1732
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we don't specify <jta-data-source>, we cannot use @PersistenceContext(unitName="EmployeeService") in the EmployeeService.java.

If we don't have <jta-data-source>, we should do this:
 
Did you ever grow anything in the garden of your mind? - Fred Rogers. Tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!