2012-03-30 25 views
1

私のアプリケーションでPostgreSQLをMySQLに置き換えようとしています。JPA/HibernateはPostgresqlで動作しますが、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:私はpersistence.xmlのファイルに<properties>を交換するために十分なものでなければならないと考え、私が取得しAMG

<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"/> 

しかし、この交換に

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

私は何が間違っているのか分かりません。交換は簡単であろう。 PostgreSQLでは、すべて正常に動作します。

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

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

例外:https://gist.github.com/2252487

ありがとう!

編集: 私は意図的に与えられたコードからユーザー名とパスワードを削除します。

+0

セッションファクトリの起動メッセージも投稿できますか? – araqnid

+0

mysqlワークベンチから指定された資格情報で接続できますか? –

答えて

6

設定を欠けては、PostgreSQL用の方言を休止:

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

EDIT:

あなたが設定でミススペルを持っている:

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

012でなければなりません
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/GoOut2"/> 

hibernateですが、hiberanteではありません。

+0

私は例に追加するのを忘れましたが、私の問題はPostgreSQL、byt MySQLではありません。 –

+1

@Vojtěch私の更新された答えを見てください。 –

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> 
関連する問題