【问题标题】:Firebird Embedded - Error while trying to open fileFirebird Embedded - 尝试打开文件时出错
【发布时间】:2012-02-14 07:33:17
【问题描述】:

我想使用 Firebird 2.5。在 .NET 4.0 项目中嵌入 NHibernate 3.2。使用 firebird 提供者的代码,这项工作非常棒。但是当我尝试配置 NHibernate

Configuration = new Configuration().Configure();

UPD:

当我尝试构建会话工厂时

Factory = Configuration.BuildSessionFactory();

发生错误:

文件“C:\MYDB.FBD”的“CreateFile(打开)”操作期间出现 I/O 错误 尝试打开文件时出错

在 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>

【问题讨论】:

  • 为什么要为嵌入式数据库指定 LOCALHOST?尝试将此属性留空。
  • @AndreiK。我试过了。但一切都没有改变。目前我正在寻找有关实施 IConnectionProvider 的一些信息

标签: .net nhibernate firebird-embedded


【解决方案1】:

我的猜测是,firebird 嵌入式使用该文件排他性,当您打开另一个会话时,它会尝试连接到同一个文件并抛出。

以下帮助之一:

  • 保持全局连接并执行OpenSession(globalConnection);
  • 实现 IConnectionProvider 以分发单个数据库连接

【讨论】:

  • 我创建的单独项目仅包含 nhibernate 的配置并得到相同的错误...也许 nhibernate 在这个阶段在里面创建了几个会话?
  • 你实现了 IConnectionProvider 吗?
  • 我试图实现这一点。谢谢你的建议!
  • FB 2.5 嵌入式允许多个同时连接到同一个数据库文件。
【解决方案2】:

因为我没有看到解决方案,所以我将添加我发现的内容 - 尽管这篇文章有多老: 在使用数据库之前,您必须致电FirebirdSql.Data.FirebirdClient.FbConnection.CreateDatabase(ConnectionString);

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

问候 胡伊·朱卡

【讨论】:

    猜你喜欢
    • 2020-11-17
    • 2021-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-11
    • 1970-01-01
    相关资源
    最近更新 更多