Detect lost database connection

Detect lost database connection

Postby 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?
marcink
 
Posts: 1
Joined: Thu 08 Aug 2013 14:00

Re: Detect lost database connection

Postby 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.
AndreyZ
 


Return to dbExpress driver for InterBase & Firebird