Firebird Embedded - 尝试打开文件时出错

发布于 2025-01-05 02:54:28 字数 1616 浏览 1 评论 0原文

我想使用 Firebird 2.5。在 .NET 4.0 项目中嵌入 NHibernate 3.2。火鸟提供商的代码工作非常出色。但是,当我尝试配置 NHibernate

Configuration = new Configuration().Configure();

UPD:

当我尝试构建会话工厂时,

Factory = Configuration.BuildSessionFactory();

会发生错误:

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

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

I want to use Firebird 2.5. Embedded with NHibernate 3.2 in .NET 4.0 project. The work is great with firebird provider's code. But when I try to configure NHibernate

Configuration = new Configuration().Configure();

UPD:

when I try to build session factory

Factory = Configuration.BuildSessionFactory();

the error occurs:

I/O error during "CreateFile (open)" operation for file "C:\MYDB.FBD"
Error while trying to open file

In the app.config everything looks fine

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

从此见与不见 2025-01-12 02:54:28

我的猜测是,嵌入式火鸟独占使用该文件,当您打开另一个会话时,它会尝试连接到同一文件并抛出异常。

以下其中一项有帮助:

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

my guess is that firebird embedded uses the file exclusivly and when you open another session it tries to connect to the same file and throws.

one of the following helps:

  • hold a global connection and do OpenSession(globalConnection);
  • implement IConnectionProvider to handout a single database connection
自我难过 2025-01-12 02:54:28

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

https://sourceforge.net/p/firebird/mailman/message/9316804/< /a>

问候
朱伊·朱卡

because I didn't see a solution I'll add what I've found - despit how old this post is:
You have to call FirebirdSql.Data.FirebirdClient.FbConnection.CreateDatabase(ConnectionString); before using the database.

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

Greetings
Juy Juka

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文