问题
I am connecting to PostgreSQL 9.5 x64 using Delphi 10 and FireDAC.
There is a reconnect feature in my software which relies on TFDConnection.Connected
flag:
if not _conn.Connected then
if _autoConnect then
_conn.Connected := True
else
raise Exception.Create('Not connected to database');
After I connect my software to PostgreSQL and start executing queries, I go to Windows services control panel and stop-start PostgreSQL server in order to test the reconnect feature. After starting PostgreSQL server I continue to get following errors:
[FireDAC][Phys][PG][libpq] no connection to the server
and TFDConnection.Connected
remains True
no matter whether PostgreSQL is started or stopped.
OnLost
, OnRecover
and OnRestored
are never fired when PostgreSQL stops.
With MS SQL Server 2012, no matter whether local or remote, everything is Ok.
How to detect PostgreSQL disconnection for sure?
Versions of my DLLs are:
libpq.dll 9.5.2.1688
LIBEAY32.dll 1.0.2.7
SSLEAY32.dll 1.0.2.7
libiconv-2.dll 1.14.0.0
libintl-8.dll 0.9.14.0
来源:https://stackoverflow.com/questions/46827156/when-postgresql-stops-tfdconnection-connected-remains-true