Detect lost database connection

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for InterBase & Firebird in Delphi and C++Builder
Post Reply
Posts: 1
Joined: Thu 08 Aug 2013 14:00

Detect lost database connection

Post by marcink » Thu 08 Aug 2013 14:45

We've bought dbx driver for Firebird and recently faced up problem with detecting lost connection. I realized that property Connected of TSQLConnection remains True although firebird was unexpectedly shut down.

How to detect the lost connection? Is it possible only while executing a statement by catching an exception?


Re: Detect lost database connection

Post by AndreyZ » Fri 09 Aug 2013 05:45

When a database server shuts down, clients that are connected to it know nothing about it. That's why, to detect a connection loss, the only way is to try to perform any operation on a server. In case of error, an exception is generated which you should catch.
Please note that if a connection error occurs, dbExpress driver for InterBase and Firebird tries to reconnect (it is controlled by the Reconnect connection option). If it is possible, connection is established again.

Post Reply