我试图用NetBeans 7.4连接到使用Hibernate 3.6.10的MySQL数据库,但是当我尝试创建新的“Hibernate映射向导”时,我回复此错误消息:Hibernate - MySQL - 连接数据库
Unable to connect: Cannot establish a connection jdbc:mysql://localhost:3306/mydbname using apache.org.derby.jdbc.ClientDriver(Unable to find a suitable driver)
这是我的“的hibernate.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.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/database</property>
<property name="hibernate.connection.username">username</property>
<property name="hibernate.connection.password">password</property>
</session-factory>
</hibernate-configuration>
我已经在这里发现了另一个类似的问题:Hibernate - Cannot connect to DB但我还是不明白什么是错的。
此致敬礼。
安德烈
类路径中的com.mysql.jdbc.Driver'类是什么? –
你在classpath中是否也有hibernate config.prop文件? – kosa
嗨罗宾和Nambari:我不得不把我的mysql驱动程序的“路径”库也config.prop路径CLASSPATH变量,但我没有这样做。谢谢。 – user2928795