JPA/Hibernate works with Postgresql, but not with Mysql
11,001
Solution 1
You missing configuration hibernate dialect for PostgreSQL:
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
EDIT:
You have miss spelling in configuration:
<property name="hiberante.connection.url" value="jdbc:mysql://localhost:3306/GoOut2"/>
should be
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/GoOut2"/>
Is hibernate
, but not hiberante
.
Solution 2
<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>
Author by
Vojtěch
Updated on June 04, 2022Comments
-
Vojtěch almost 2 years
I am trying to replace PostgreSQL in my application with MySQL. I thought that it should be sufficient to replace the
<properties>
in persistence.xml file: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"/>
But with this replacement, I amg getting
java.lang.UnsupportedOperationException: The application must supply JDBC connections
I am not sure what I am doing wrong, I just hoped that the replacement would be straightforward. In PostgreSQL, everything works correctly.
Persistence.xml: https://gist.github.com/2252443
applicationContext.xml: https://gist.github.com/2252463
exception: https://gist.github.com/2252487
Thanks!
EDIT: I remove username and password from the given code intentionally.
-
araqnid about 12 yearscan you post the startup messages for the session factory as well?
-
Sinisha Mihajlovski about 12 yearscan you connect from mysql workbench with the given credential information?
-
-
Vojtěch about 12 yearsI just forgot to add it to the example, but my problem is not PostgreSQL, byt MySQL.