Disconnect detection

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
wjm4
Posts: 72
Joined: Mon 12 Feb 2007 21:31

Disconnect detection

Post by wjm4 » Mon 18 Feb 2013 23:32

What is the best way to detect when an oracle connection is disconnected and reconnect? I have the following scenario:
1) connect to database with direct option
2) preform query and get results
3) connection is lost to the server
4) preform another query that is unsuccessful. However, when I check the connected property of the connection before running, it says true. I have also tried to put code in the onsessionerror method but that does not get called every time the query->execute gets called.

What is the best way to deal with a connection that can go down?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Disconnect detection

Post by AlexP » Thu 21 Feb 2013 09:47

Hello,

You can use the TOraSession.onConnectionLost event and set the RetryMode parameter in it to the rmReconnectExecute value. In this case, when attempting to execute the query, if connection is lost, there will be an attempt to reconnect and execute the query. To use this event, you should add the MemData module to the uses section and set the TOraSession.Options.LocalFailover property to True.

Post Reply