问题
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