Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exception with JPA application

 
Anil Deshpande
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the code of the application:


persistance.xml



main method:



And the Exception it is throwing is:





How to Solve this Problem?
 
Shannon McGee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anil,

The first thing that caught my eye is that your password is never set. Did you remove it to post the example, or forgot to set it in your code?

It looks like your persistence.xml file is never read. Is it on the classpath?

-Shannon
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are using the wrong persistence unit properties for your connection as you are using EclipseLink, not TopLink,

change to:
<property name="eclipelink.jdbc.url" value="jdbc:mysql://localhost/experiments"/>
<property name="eclipelink.jdbc.user" value="root"/>
<property name="eclipelink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="eclipelink.jdbc.password" value=""/>
<property name="eclipelink.ddl-generation" value="create-tables"/>
<property name="eclipelink.jdbc.connections.min" value="1"/>
<property name="eclipelink.jdbc.connections.max" value="2"/>
<property name="eclipelink.logging.level" value="FINEST"/>

or, since you are using EclipseLink 1.2 which supports JPA 2.0 use the standard JPA 2.0 JDBC properties:
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/experiments"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.password" value=""/>
<property name="eclipelink.ddl-generation" value="create-tables"/>
<property name="eclipelink.jdbc.connections.min" value="1"/>
<property name="eclipelink.jdbc.connections.max" value="2"/>
<property name="eclipelink.logging.level" value="FINEST"/>
 
Anil Deshpande
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no password set for the database. that is why I have not given the password. And After I did the changes to the persistance .xml as indicated by James Still I am getting the exception? I did the both the changes. But still it gives the same problem.

The Exception is


Just to check whether I am using proper driver and url, I tried jdbc program with connection and manager, It works perfectly fine. I don't understand where the problem is?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic