2012-02-14 84 views
0

我想使用Firebird 2.5。在.NET 4.0項目中嵌入了NHibernate 3.2。 Firebird提供者的代碼非常棒。但是,當我嘗試配置NHibernate的Firebird嵌入式 - 嘗試打開文件時出錯

Configuration = new Configuration().Configure(); 

UPD:

當我嘗試建立會話工廠

Factory = Configuration.BuildSessionFactory(); 

出現錯誤:

I/O錯誤時文件「C:\ MYDB.FBD」的「CreateFile(open)」操作 嘗試打開時出錯文件

在App.config一切都看起來不錯

<configSections> 
    <section 
     name="hibernate-configuration" 
     type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" 
    /> 
</configSections> 
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> 
    <session-factory> 
      <property name="connection.driver_class">NHibernate.Driver.FirebirdClientDriver</property> 
      <property name="connection.connection_string"> 
       Server=localhost; 
       ServerType=1; 
       Database=C:\MYDB.FBD; 
       User=SYSDBA;Password=masterkey 
      </property> 
      <property name="show_sql">true</property> 
      <property name="dialect">NHibernate.Dialect.FirebirdDialect</property> 
      <property name="command_timeout">60</property> 
      <property name="query.substitutions">true 1, false 0, yes 1, no 0</property> 
    </session-factory> 
</hibernate-configuration> 
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" /> 
</startup> 

+0

爲什麼你指定嵌入式數據庫LOCALHOST?儘量保持這個屬性爲空。 – 2012-02-16 05:06:09

+0

@AndreiK。我試過了。但沒有任何變化。目前我正在尋找一些有關實施IConnectionProvider的信息 – 2012-02-16 09:17:11

回答

0

我的猜測是,火鳥嵌入式使用文件exclusivly,當您打開另一個會話它會嘗試連接到同一個文件並拋出。

以下的人幫助:

  • 舉行一個全球性的連接,並做OpenSession(globalConnection);
  • 實施IConnectionProvider以施捨一個數據庫連接
+0

我創建的單獨項目只包含配置nhibernate並得到相同的錯誤...也許nhibernate在這個階段創建了幾個會話裏面? – 2012-02-14 11:46:13

+0

你有沒有實現IConnectionProvider? – Firo 2012-02-14 13:14:35

+0

我試圖實現這一點。感謝您的建議! – 2012-02-16 11:56:07

0

,因爲我沒有看到一個解決方案,我」將添加我發現的內容 - despit這篇文章的年齡: 您必須在使用數據庫之前先致電FirebirdSql.Data.FirebirdClient.FbConnection.CreateDatabase(ConnectionString);

https://sourceforge.net/p/firebird/mailman/message/9316804/

問候 Juy Juka