如何配置Hibernate支持MySql

配置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如下

MyTest
false
true
net.sf.hibernate.dialect.MySQLDialect


但是程序运行到InitialHibernate处出现以下错误
javax.naming.NameNotFoundException: Name gt3k is not bound in this Context

请指点


// 在此输入java代码
hibernate.connection.url jdbc:mysql:MyTest
你这是什么意思?URL不对!
其实可以直接使用jndi的,这样就避免了在hibernate上的配置.
为什么你又有progreSQL又有mysql ?

按照错误 是 gt3k 这个jndi-name找不到.

我原来配置mysql的例子:你参考一下吧


true
root
jdbc:mysql://localhost:3306/computer
org.hibernate.dialect.MySQLDialect
123456
org.gjt.mm.mysql.Driver
10
true
0