Netbeans + derby + hibernate

被刻印的时光 ゝ 提交于 2019-12-14 02:19:15

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/3322575/netbeans-derby-hibernate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!