Netbeans +德比战休眠
我正在关注 http://netbeans.org/kb/docs/ java/hibernate-java-se.html 学习在 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>
并且可以在以下位置访问数据库:这条路。
有什么想法吗?
I'm following http://netbeans.org/kb/docs/java/hibernate-java-se.html tute to setup hibernate with derby in netbeans IDE.
Netbeans fails to create hibernate.reveng.xml with error : "Cannot establish database connection with selected Hibernate Configuration file. Please verify the database connection details in hibernate.cfg.xml"
My hibernate.cfg.xml looks like this
<?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>
and database is accessible on this path.
Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是猜测,但您可能仍有 SQL 客户端连接。或者数据库可能没有正确关闭。尝试指定
shutdown=true
在连接字符串中。实际上,我的建议是在服务器模式下使用 Derby,NetBeans 对其提供了出色的支持。请参阅使用 Java DB (Derby) 数据库。
Just a guess but you have maybe an SQL client still connected. Or maybe the database didn't shutdown properly. Try to specify a
shutdown=true
in the connection string.Actually, my suggestion would be to use Derby in server mode, NetBeans provides excellent support for it. See Working with the Java DB (Derby) Database.