2013-02-22 65 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

希望幫助打開。