• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

exception with JPA application

 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Where all the women are strong, all the men are good looking and all the tiny ads are above average:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic