我目前正在尝试通过这个netbeans hibernate JavaSE教程(http://netbeans.org/kb/docs/java/hibernate-java-se.html).一切都很好,但是在创建hibernate.cfg.xml之后,当涉及到应该应用逆向工程的部分时,反向工程向导会告...

我目前正在尝试通过这个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向导找不到数据库驱动程序


基础教程推荐
- JavaWeb Hibernate使用全面介绍 2023-06-24
- java – 在JSP中更新数据库 2023-10-31
- springboot如何使用thymeleaf完成页面缓存 2022-12-27
- 基于Java实现收发电子邮件功能 2023-03-06
- SSM框架整合JSP中集成easyui前端ui项目开发示例详解 2023-07-30
- 详解Java中的字节码增强技术 2023-06-10
- Java数据结构之栈与综合计算器的实现 2023-06-24
- IDEA 中使用 Hudi的示例代码 2023-01-02
- Servlet网上售票问题引发线程安全问题的思考 2023-08-03
- spring-boot项目启动迟缓异常排查解决记录 2022-11-08