【问题标题】:JDBC Driver class not found找不到 JDBC 驱动程序类
【发布时间】:2011-05-03 08:57:22
【问题描述】:

我在运行类测试时遇到了休眠配置问题:

creating session factory
3 mai 2011 09:47:50 net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.1.6
3 mai 2011 09:47:50 net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
3 mai 2011 09:47:50 net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
3 mai 2011 09:47:50 net.sf.hibernate.cfg.Configuration configure
INFO: configuring from file: hibernate.cfg.xml
3 mai 2011 09:47:51 net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: org/domain/projet/config/Employe.hbm.xml
3 mai 2011 09:47:52 net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: org.domain.projet.config.Employe -> employe
3 mai 2011 09:47:52 net.sf.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: 
3 mai 2011 09:47:52 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
3 mai 2011 09:47:52 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
3 mai 2011 09:47:52 net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
3 mai 2011 09:47:52 net.sf.hibernate.cfg.SettingsFactory buildSettings
ATTENTION: No dialect set - using GenericDialect: Dialect class not found: org.hibernate.dialect.MySQLDialect
3 mai 2011 09:47:52 net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.GenericDialect
3 mai 2011 09:47:52 net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use outer join fetching: true
3 mai 2011 09:47:52 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
3 mai 2011 09:47:52 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 1
JDBC Driver class not found: com.jdbc.mysql.driver
3 mai 2011 09:47:52 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
GRAVE: JDBC Driver class not found: com.jdbc.mysql.driver

【问题讨论】:

    标签: java hibernate jdbc


    【解决方案1】:

    您的类路径中需要mysql-connector-*.jar

    【讨论】:

    • 但我有 mysql 5.0 的连接器但无法正常工作 :( 我放入了休眠配置文件:com.jdbc.mysql.driver
    【解决方案2】:

    尝试使用这些属性值:

    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
     ...
    <property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
    

    检查hibernate3.jar 是否也在您的路径中。

    【讨论】:

    • 谢谢我发现错误是 net.fr.hibernate.dialect.MYSQLDialect :)
    【解决方案3】:
    找不到JDBC驱动类:com.jdbc.mysql.driver

    全限定类名区分大小写。您需要在 Hibernate 配置文件中使用大写的 D 声明 com.mysql.jdbc.Driver,而不是使用小写的 d 声明 com.mysql.jdbc.driver

    【讨论】:

      猜你喜欢
      • 2012-02-05
      • 1970-01-01
      • 1970-01-01
      • 2011-04-12
      • 2015-06-15
      • 2013-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多