如何配置Hibernate支援MySql

wangkent發表於2003-09-05
配置Tomcat+MySql+Hibernate
我修改了Hibernate.properties設定使用PostgreSQLDialect

hibernate.dialect net.sf.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class org.gjt.mm.mysql.Driver
hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc:mysql:MyTest
hibernate.connection.username root
hibernate.connection.password root


修改hibernate.cfg.xml如下
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

<session-factory>

<property name="connection.datasource">MyTest</property>
<property name="show_sql">false</property>
<property name="use_outer_join">true</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>

<!-- Mapping files -->
<mapping resource="Cat.hbm.xml"/>

</session-factory>

</hibernate-configuration>

但是程式執行到InitialHibernate處出現以下錯誤
javax.naming.NameNotFoundException: Name gt3k is not bound in this Context

請指點

相關文章