0

I am trying to use JPA with Spring MVC using maven. I am new to all three and am stuck at trying to follow the steps in http://www.objectdb.com/tutorial/jpa/eclipse/web..Instead of objectDB, I am using MySQL.. I have added the following dependency to pom.xml

 <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.6</version>
    </dependency>

Following is my persistence.xml

  <persistence-unit name="GuestbookPU" >
    <provider>com.objectdb.jpa.Provider</provider>
    <!-- <properties>
      <property name="javax.persistence.jdbc.url" value="$objectdb/db/guests.odb"/>
      <property name="javax.persistence.jdbc.user" value="admin"/>
      <property name="javax.persistence.jdbc.password" value="admin"/>
    </properties> -->
    <properties>
        <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
        <property name="javax.persistence.jdbc.url" value="jdbc:mysql://172.22.201.142:3306/" />
        <property name="javax.persistence.jdbc.user" value="tcm_user" />
        <property name="javax.persistence.jdbc.password" value="tcm_pwd" />
    </properties>
  </persistence-unit>

Also, I am using Tomcat and I am not sure if it supports JPA, so I tried tomEE but I am still getting error

java.io.FileNotFoundException: jdbc:mysql:\172.22.201.142:3306 (The filename, directory name, or volume label syntax is incorrect)

The rest of the modules are same as the tutorial, please let me know where I am going wrong.

SKaul
  • 349
  • 2
  • 7
  • 22

1 Answers1

0

You seem to want to use MySQL, yet have put the "persistence provider" as ObjectDB. That is a contradiction. ObjectDB as a JPA provider only supports persistence to itself (an Object Database - ODBMS); ask yourself where in the ObjectDB docs did it say it supports persistence to MySQL?.

MySQL is an RDBMS datastore, so if you want to use MySQL then you use a JPA provider that support MySQL, such as DataNucleus JPA for example

DataNucleus
  • 15,497
  • 3
  • 32
  • 37
  • Thanks for replying, I am trying to use JPA as here: http://www.javabeat.net/jpa/ ..but I did not know about the JPA providers concept. Could I use JPA with mySQL and SPring MVC without a particular provider or am I conceptually wrong ? – SKaul Jan 30 '14 at 11:40
  • http://stackoverflow.com/questions/9881611/whats-the-difference-between-jpa-and-hibernate after reading this, it seems I could use JPA alone, then how could I use it in the context ? – SKaul Jan 30 '14 at 11:54
  • Obviously you can't use "JPA alone" ... as that thread says, its just interfaces. You have to have a "JPA provider"; any decent book on the subject would tell you that – DataNucleus Jan 30 '14 at 14:13