我正在使用带有基本 hibernate 程序的 MySQL Workbench 5.2 CE 数据库 在运行时它给我错误:
Caused by: org.hibernate.HibernateException: JDBC Driver class not found: com.mysql.jdbc.Driver
hibernate.cfg.xml 中的这段代码:
<hibernate-configuration>
<session-factory>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.url">jdbc:mysql://192.168.8.212/da?autoReconnect=true&useOldUTF8Behavior=true&useUnicode=true&characterEncoding=UTF-8" /></property>
<property name="connection.username">root</property>
<property name="connection.password">password</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="myeclipse.connection.profile">MyEclipse Derby</property>
</session-factory>
</hibernate-configuration>
最佳答案
把 mysql jdbc driver jar在您的类路径上 - 如果它是 WEB-INF/lib
关于java - Hibernate基础程序中的org.hibernate.HibernateException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3493242/