我目前正在尝试通过这个netbeans hibernate JavaSE教程(http://netbeans.org/kb/docs/java/hibernate-java-se.html).一切都很好,但是在创建hibernate.cfg.xml之后,当涉及到应该应用逆向工程的部分时,反向工程向导会告...
![](https://oss.womengda.net/imgfile/2310/1ER05T523910-1WU.jpg)
我目前正在尝试通过这个netbeans hibernate JavaSE教程(http://netbeans.org/kb/docs/java/hibernate-java-se.html).一切都很好,但是在创建hibernate.cfg.xml之后,当涉及到应该应用逆向工程的部分时,反向工程向导会告诉我一些奇怪的消息:
"The database drivers are not added to the project classpath."
"Go to project properties to add database library.".
嗯,这有点奇怪,因为hibernate.cfg.xml是由netbeans生成的.我已经用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/sakila</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">apassword</property>
<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
</session-factory>
</hibernate-configuration>
解决方法:
在hibernate.cfg.xml中添加这些代码
<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/DATABASE_NAME</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"/>
</session-factory>
本文标题为:java – Netbeans 7.1 Hibernate Reverse Engineering向导找不到数据库驱动程序
![](/xwassets/images/pre.png)
![](/xwassets/images/next.png)
- SpringCloud使用集中配置组件Config规避信息泄露 2023-03-06
- 图解Java经典算法归并排序的原理与实现 2023-05-14
- Java设计模式中的组合模式 2023-03-11
- Java深入分析讲解反射机制 2022-11-29
- Spring Boot实现文件上传下载 2023-04-12
- Java类型转换valueOf与parseInt区别探讨解析 2023-06-01
- 关于后缀表达式的java实现过程 2023-02-28
- Java CompletableFuture实现多线程异步编排 2023-05-14
- SpringBoot中定时任务@Scheduled注解的使用解读 2023-06-06
- 使用maven自定义插件开发 2023-01-08