【问题标题】:org.hibernate.HibernateException in a basic program of HibernateHibernate基本程序中的org.hibernate.HibernateException
【发布时间】:2011-03-30 10:12:22
【问题描述】:

我正在使用带有基本休眠程序的 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&amp;useOldUTF8Behavior=true&amp;useUnicode=true&amp;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>

【问题讨论】:

  • 这无关,但您的 connection.url 字符串末尾有一些额外的垃圾,请删除它们。应该是&lt;property name="connection.url"&gt;jdbc:mysql://192.168.8.212/da?autoReconnect=true&amp;amp;useOldUTF8Behavior=true&amp;amp;useUnicode=true&amp;amp;characterEncoding=UTF-8&lt;/property&gt;

标签: java mysql hibernate orm


【解决方案1】:

mysql jdbc driver jar 放在你的类路径中——如果它是一个WEB-INF/lib 的Web 应用程序

【讨论】:

  • 我已经把它放在类路径中:Hibernate 3.3 Annotations & Entity Manager, Hibernate 3.3 Core Libraries, Hibernate 3.3 Advanced Support Libraries, derbyclient.jar - Hibernate_example/lib
  • 我已经链接到驱动程序下载页面,您可以从那里获得jdbc驱动程序,并将其放在类路径中。
猜你喜欢
  • 2011-03-30
  • 1970-01-01
  • 2016-03-31
  • 1970-01-01
  • 2011-02-17
  • 2017-12-18
  • 2013-04-05
  • 2013-09-14
  • 1970-01-01
相关资源
最近更新 更多