Voj*_*ěch 1 java mysql postgresql hibernate jpa
我试图用MySQL替换我的应用程序中的PostgreSQL.我认为替换<properties>in persistence.xml文件应该足够了:
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"/>
Run Code Online (Sandbox Code Playgroud)
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"/>
Run Code Online (Sandbox Code Playgroud)
但是有了这个替代品,我得到了
java.lang.UnsupportedOperationException: The application must supply JDBC connections
Run Code Online (Sandbox Code Playgroud)
我不确定我做错了什么,我只是希望更换是直截了当的.在PostgreSQL中,一切正常.
Persistence.xml:https://gist.github.com/2252443
applicationContext.xml:https://gist.github.com/2252463
例外:https://gist.github.com/2252487
谢谢!
编辑:我故意从给定的代码中删除用户名和密码.
你缺少PostgreSQL的配置hibernate方言:
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
Run Code Online (Sandbox Code Playgroud)
编辑:
您在配置中错过了拼写:
<property name="hiberante.connection.url" value="jdbc:mysql://localhost:3306/GoOut2"/>
Run Code Online (Sandbox Code Playgroud)
应该
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/GoOut2"/>
Run Code Online (Sandbox Code Playgroud)
是hibernate,但不是hiberante.