我正在关注 http://netbeans.org/kb/docs/java/hibernate-java-se.html tute 在 netbeans IDE 中使用 derby 设置 hibernate 。
Netbeans 无法创建 hibernate.reveng.xml 并出现错误:“无法与选定的 Hibernate 配置文件建立数据库连接。请验证 hibernate.cfg.xml 中的数据库连接详细信息”
我的 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.connection.driver_class">org.apache.derby.jdbc.EmbeddedDriver</property>
<property name="hibernate.connection.url">jdbc:derby:G:\projects\Java\DesktopApplication1\db;create=true</property>
<property name="hibernate.connection.username">user</property>
<property name="hibernate.connection.password">***</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
</session-factory>
</hibernate-configuration>
并且可以通过这条路径访问数据库。
有什么想法吗?
最佳答案
Found this in netbeans log file: java.sql.SQLException: Another instance of Derby may have already booted the database G:\projects\Java\DesktopApplication1\db.
只是一个猜测,但您可能仍然连接着一个 SQL 客户端。或者数据库没有正常关闭。尝试指定一个 shutdown=true
在连接字符串中。
实际上,我的建议是在服务器模式下使用 Derby,NetBeans 对此提供了出色的支持。参见 Working with the Java DB (Derby) Database .
关于java - Netbeans + Derby + hibernate ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3322575/