2013-02-22 83 views
0

我正在开发一个使用Netbeans休眠和MySQL的应用程序,这工作得很好。 将后台切换到Derby嵌入式数据库时,hibernate无法执行逆向工程。打开NETbeans休眠和mysql到derby嵌入式

随着消息:cannot access database with the configuration in "hibernate.cfg"

我的配置:

<hibernate-configuration> 
    <session-factory> 
    <property name="hibernate.default_schema">servlandDERBY</property> 
    <property name="hibernate.connection.driver_class">org.apache.derby.jdbc.EmbeddedDriver</property> 
    <property name="hibernate.connection.url">jdbc:derby:servlandDERBY</property> 
    <property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property> 
    <property name="hibernate.show_sql">true</property> 
    <property name="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</property> 
</session-factory> 

我已经包括在我的项目jar文件JavaDB之外,其中包括的derby.jar 我必须作出任何其他Netbeans中的设置或额外配置?

+0

我的回答可以帮到你吗? – 2013-02-25 19:24:18

回答

0

网络和嵌入式

的Java DB(网络)

属性字符串:

<property 
name="hibernate.connection.driver_class">org.apache.derby.jdbc.ClientDriver 
</property> 

创建新的连接测试里面的Netbeans您的数据库。

  • A)转到服务 - 数据库(右键) - 新建连接
  • B)尝试创建一个新的连接
  • C)驱动程序德比OK?
  • d)打开的连接

enter image description here

设置正确的设置

  • A)数据库URL
  • B)驱动器 - org.apache.derby.jdbc。ClientDriver

enter image description here

的Java DB(嵌入式)

右击 - 的Java DB(嵌入式) - 连接使用

enter image description here

  • 填写表格如下所述
  • 单击测试连接

enter image description here

现在你可以看到新的连接

enter image description here

新连接的属性!当心数据库URL

enter image description here

属性字符串:

<property 
name="hibernate.connection.driver_class">org.apache.derby.jdbc.EmbeddedDriver 
</property> 
<property 
name="hibernate.connection.url">jdbc:derby:C:/Dokumente und Einstellungen/Administrator/.netbeans-derby/sample 
</property> 
<property name="hibernate.connection.username">app</property> 
<property name="hibernate.connection.password">app</property> 

如果你得到一个错误

这意味着
该数据库由嵌入式连接打开

enter image description here

这意味着
数据库是通过网络连接

enter image description here

希望帮助打开。