火鸟 ISC 错误 CODE:335544721

Firebird ISC ERROR CODE:335544721

我们的客户最近报告了这个错误,我们不知道如何解决这个问题。我们正在使用 Delphi XE6 来开发我们的应用程序,它作为后端连接到 Firebird (v2.5) 数据库。我们还在 Delphi 中使用 IBObjects 来处理 Firebird 数据库。 我们已经设法通过在 运行 查询之前停止 Firebird windows 服务来在开发机器上复制错误,但是我们还没有找到一种方法来检测代码中丢失的连接(例如通过事件) 因为我们不知道什么时候会发生这种情况,所以我们也无法在代码中重新连接到数据库。

顺便说一句,这是完整的错误信息,如果它有帮助的话:

ISC 错误 CODE:335544721 ISC 错误信息: 无法完成对主机 "BON-VFS-01" 的网络请求。 将数据写入连接时出错。

非常感谢任何帮助。

来自 IBOBjects FAQ

Is there a way to detect a lost connection and try to reconnect automatically, without user action?

Hook into the OnError event and look for the ERRCODE that denotes a lost connection. Then, you can take whatever action you deem necessary to deal with the problem. If the connection is lost you need to do a disconnect and then connect again.

并且来自 IBObjects 的基本成员之一:

However, perhaps the "something" you are missing is that, if the connection is broken by an external cause, the client application has no way to know that it is not still connected. Its first knowledge of that fact will come the next time it tries to access the server. The API will report "Connection lost to database" and return GDSCODE 335544741, which is identified by the constant isc_lost_db_connection.

At the point where this exception occurs, the TIB_Connection still thinks it is connected - the Connected property will be true. If you try to reconnect by calling Connect, you will get an IBO exception. It is necessary to call Disconnect. This does not simply reset a property. The Disconnect method performs all of the necessary cleanup to invalidate the broken transactions and cancel any now invalid postings, datasets and caches. Once Disconnect has completed its work, you can then place a Connect call inside a retry loop and attempt to get going again.

I do not know of a working example, but the simplest way to deal with this is to write a RestoreConnection handler procedure that you can call from your IB_Session.OnError handler whenever argument ERRCODE returns isc_lost_db_connection.

Have your RestoreConnection procedure do whatever you need to do, trying to call Connect and handling the exception that occurs if the request fails, until no exception occurs. Test the Connected property after each iteration. When Connected is finally True, you are in business. You can drop out of the retry code and inform the user that the connection has been restored - perhaps with a sound and/or a message in the status bar, to avoid having to show a dialog box that she has to respond to. (if you like the idea of sound and status bar cues, you could devise "connection lost" warning sound and status bar message code to run at the beginning of your handler procedure as well...)

If these broken connections are a frequent occurrence, you might like to consider making a distinctive custom cursor that you can display while your procedure is running, and enclose the retry code in a non-yielding BeginBusy...EndBusy block with UseCursor enabled and BusyCursor set to use this special cursor image.

And if re-establishing a connection is likely to take a long time, or to be temporarily impossible, you would need to provide the ability for the user to intervene and choose not to keep trying. You can use the session timer for this, enclosing your "busy" block inside another iterative block the prompts the user to "Cancel" or "Keep Trying", at reasonable intervals.

Source

检查他们的数据库文件是否位于映射的网络驱动器上。即使数据库文件路径似乎是文件系统的本地路径,当使用嵌入式 Firebird 服务器时,函数 isc_attach_database 也会 return 尝试建立连接时出现错误代码 335544721。当我第一次共享整个主机 D 驱动器然后再次将其映射为虚拟客户机 OS 中的 D 驱动器时,我的 VirtualBox 客户机 Windows XP 上确实发生了这种情况。

解决方法是将数据库文件移动到本地分区驱动器。

检查您的查询长度

最大查询长度为 8191 个字符 UTF-8

它解决了我的问题

将您的电脑连接到互联网,问题将得到解决,但我不知道它是如何工作的