• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA Pro 2 (2nd edition) chapter 2 persistence.xml needs to be updated

 
Himai Minh
Ranch Hand
Posts: 1359
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,  I am reading chapter 2 of this text book.
I think the persistence.xm file should be updated into this:

<?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="EmployeeService">
<class>examples.model.Employee</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/murach_jpa" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="sesame" />
</properties>
</persistence-unit>
</persistence>
Make sure you have mysql-connector-java-5.1.39-bin.jar in your build path.
Assume you have download MySQL and assume there is a database called murach_jpa.
I am using this database created in Murach's JSP/Servlet book.

 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If would have been better if you'd use the "Code" rather than the "Quote" option on that sample. The code tags preserve spacing and formatting in sample XML and Java.

It would have been even better if you'd indicating what precisely you changed from the book's sample persistence.xml.

If if was the mysql jdbc jar version, that's not usually essential, since the mysql jdbc driver's basic functionality isn't that different between most of its versions.
 
Himai Minh
Ranch Hand
Posts: 1359
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Tim.
Thanks for pointing out. I recommend to download the latest version of mySQL connector.
I added the <class>  and <properties>, which do not exist in the original code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic