[Lazarus] Is there a way to reconnect to postgresql if the connection fails?
Michael Van Canneyt
michael at freepascal.org
Tue May 15 21:11:56 CEST 2018
On Tue, 15 May 2018, Luca Olivetti wrote:
> El 15/05/18 a les 20:44, Michael Van Canneyt ha escrit:
>
>>>
>>> Is there a way to force the closing of a connection in this case so I can
>>> try and reopen it again?
>>
>> Try using forcedclose in SQLDb:
>>
>> TheDatabase.Close(True);
>
> Project project1 raised exception class 'EPQDatabaseError' with message:
> PQConnection1: connection pointer is NULL
> (PostgreSQL:)
>
> In file 'fcl-db/src/sqldb/postgres/pqconnection.pp' ad line 725:
> raise E;
>
>
> TDatabase.DoDisconnect calls CloseDatasets which in turn calls
> Unprepare (in TCustomSQLQuery.SetActive)->
> FStatement.Unprepare->
> DoUnprepare->
> Database.UnPrepareStatement(FCursor)->
> TPQConnection.UnprepareStatement which eventually fails.
I will need to check this, but the purpose of Close(True) is exactly to
ignore errors while closing for a reconnect.
It was introduced and tested in the case of MySQL, but
normally should work on any database.
Can you please post a small sample program in the bugtracker ?
Michael.
More information about the Lazarus
mailing list