Skip to content
Advertisement

What is the name dialect class for mysql 10.1.21-MariaDB

in hibernate.cfg.xml

i am using MariaDBDialect class

<hibernate-configuration>
<session-factory>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/Book</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.connection.password"></property>
    <property name="hibernate.connection.pool_size">1</property>
    <property name="hibernate.current_session_context_class">thread</property>
    <property name="hibernate.show_sql">true</property>
    <property name="hibernate.dialect">org.hibernate.dialect.MariaDBDialect</property>

    <mapping class="com.yazeed.brain.dto.User" />
</session-factory>

when i run my code i got this errors in console

Exception in thread "main" org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: org.hibernate.exception.SQLGrammarException: Error calling Driver#connect 
Caused by: java.sql.SQLSyntaxErrorException: Unknown database 'book'

Advertisement

Answer

You should use org.hibernate.dialect.MySQLDialect, because MariaDB is 100% compatible with mysql.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement