I am using Hibernate 3 and MySQL5.5.
I'm new to hibernation and I get below Exception
Exception in thread "main" org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection available at org.hibernate.dialect.resolver.DialectFactory.buildDialect(DialectFactory.java:106) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:152)
I set the Dialect property in the hibernate.cfg.xml file. I tried many combinations
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property> <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property> <property name="DIALECT">org.hibernate.dialect.MySQL5Dialect</property>
What is the actual name of the property? Hibernate.dialect or just a dialect? What are the possible property values?
I add additional information, I used
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
as suggested below.
I don't even create code just trying to create a simple configuration:
Configuration cfg = new Configuration().addClass(Employee.class); sessionFactory = cfg.buildSessionFactory();
Below is the actual configuration file
<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="connection.url">jdbc:mysql://localhost/test</property> <property name="connection.username">root</property> <property name="connection.password">root1234</property> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="show_sql">true</property> <property name="format_sql">true</property> <property name="hbm2ddl.auto">create</property> <property name="connection.pool_size">1</property> <property name="current_session_context_class">thread</property> </session-factory> </hibernate-configuration>
I suspect hibernate.cfg.xml was not found? I placed it in the same package where there is source code for Employee.class. Infact navigating through this file causes the same error, so you canβt actually find it :-( Where to save it? This is a stand-alone test program: - (
source share