iT邦幫忙

0

Hibernate連接資料庫出現錯誤

使用資料庫為MYSQL
在連接資料庫的時候有錯誤
錯誤訊息:

hibernate reading schema error :hibernate.dialect must be set when no Connection available
http://ithelp.ithome.com.tw/upload/images/20170505/20104799NPP9f7720s.png
這是我的cfg.xml :

<?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.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.password">1111</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/contactdb?zeroDateTimeBehavior=convertToNull</property>
        <property name="hibernate.connection.username">Root</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
      <!--  <property name="dialect">org.hibernate.dialect.MySQLDialect</property>  --> 
        
        <mapping resource="com/sh/value/Contact.hbm.xml"/>  
    </session-factory>
</hibernate-configuration>

這是我的hbm.xml :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.sh.value">
	<class name="com.sh.value.Contact" table="contactdb" catalog="contact">
		<id name="id" column="id">
			<generator class="increment"></generator>
		</id>
		<property name="name" column="name" />
		<property name="email" column="email" />
		<property name="address" column="address" />
		<property name="telephone" column="telephone" />		
	</class>	
</hibernate-mapping>

在網路上爬了很多國外的文章,但都沒有解決,請各位前輩指點一下!

hibernate.dialect must be set when no Connection available
MySQL是否可以正常连接?
chousen iT邦新手 5 級 ‧ 2017-05-05 15:56:37 檢舉
可以唷,我使用MySQL Query Browser可以正常連線

尚未有邦友回答

立即登入回答