Netbeans +德比+休眠 [英] Netbeans + derby + hibernate

查看:118
本文介绍了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.0encoding =UTF-8?> 
<!DOCTYPE hibernate-configuration PUBLIC - // Hibernate / Hibernate Configuration DTD 3.0 // ENhttp://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>用户< / 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>

并且数据库可以在此路径上访问。



任何想法?

解决方案


在netbeans日志文件中发现:java.sql.SQLException:另一个Derby实例可能已经引导了数据库G:\projects\Java\DesktopApplication1\db。


只是一个猜测,但你可能有一个SQL客户端仍然连接。或者也许数据库没有正常关闭。尝试指定一个 shutdown = true 。实际上,我的建议是在服务器模式下使用Derby,NetBeans为它提供了极好的支持。请参阅使用Java DB(德比)数据库


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?

解决方案

Found this in netbeans log file: java.sql.SQLException: Another instance of Derby may have already booted the database G:\projects\Java\DesktopApplication1\db.

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.

这篇关于Netbeans +德比+休眠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆