2012-03-30 14 views
1

Ich versuche, PostgreSQL in meiner Anwendung durch MySQL zu ersetzen. Ich dachte, dass es ausreichend sein sollte, die <properties> in persistence.xml Datei zu ersetzen:JPA/Hibernate arbeitet mit Postgresql, aber nicht mit Mysql

PostgreSQL:

<property name="hibernate.connection.url" value="jdbc:postgresql://localhost/postgres"/> 
<property name="hibernate.connection.username" value=""/> 
<property name="hibernate.connection.password" value=""/> 
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/> 
<property name="hibernate.show_sql" value="true"/> 

MySQL:

<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> 
<property name="hiberante.connection.url" value="jdbc:mysql://localhost:3306/GoOut2"/> 
<property name="hibernate.connection.username" value=""/> 
<property name="hibernate.connection.password" value=""/> 
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> 
<property name="hibernate.hbm2ddl.auto" value="update"/> 

Aber mit diesem Ersatz, ich amg bekommen

java.lang.UnsupportedOperationException: The application must supply JDBC connections 

Ich bin mir nicht sicher, was ich falsch mache, ich hoffte nur, dass die Ersatz wäre einfach. In PostgreSQL funktioniert alles korrekt.

persistence.xml: https://gist.github.com/2252443

applicationContext.xml: https://gist.github.com/2252463

Ausnahme: https://gist.github.com/2252487

Dank!

EDIT: Ich entferne Benutzernamen und Passwort aus dem angegebenen Code absichtlich.

+0

können Sie auch die Startnachrichten für die Sitzungsfactory posten? – araqnid

+0

können Sie von Mysql Workbench mit den angegebenen Anmeldeinformationen Informationen verbinden? –

Antwort

6

Sie fehlende Konfiguration Hibernate Dialekt für PostgreSQL:

<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/> 

EDIT:

Sie haben Miss Rechtschreibung in configuration:

<property name="hiberante.connection.url" value="jdbc:mysql://localhost:3306/GoOut2"/> 

sollte

<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/GoOut2"/> 

ist , aber nicht hiberante.

+0

Ich habe nur vergessen, es zu dem Beispiel hinzuzufügen, aber mein Problem ist nicht PostgreSQL, byt MySQL. –

+1

@ Vojtěch sehe meine aktualisierte Antwort. –

1
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
     <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> 
     <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/demo</property> 
     <property name="hibernate.connection.username">root</property> 
     <property name="hibernate.connection.password">root</property> 
Verwandte Themen