Hi,
Actually i would like to ask if there is any chance to recover connection to db
after connection lost for a while/server reboot?
I always get DBNETLIB err + app crash and there is no information about how to realize it on unidac.
I found example for ADO like:
while not ADOConnection.Connected and not Terminated do
begin
Sleep(TIMEOUT_CONN_RESTORE);
ADOConnection.Close;
try
ADOConnection.Open;
except
end;
end;
and confirmation that it is done in anydac component.
Whati is the situation with unidac?
Thank you.
Connection recovery to db
Hello,
To resume lost connection, you should use the TUniConnection.OnConnectionLost event handler. The OnConnectionLost event handler is used to process fatal errors and perform failover. To make the OnConnectionLost event handler work, you should set the TUniConnection.Options.LocalFailover property to True. Note that to use the OnConnectionLost event handler, you should add the MemData unit to the USES clause of your unit. Here is an example of using the OnConnectionLost event handler:In this case, if connection was lost, UniDAC will try to reconnect and reexecute the abortive operation. For more information, please read the UniDAC documentation.
To resume lost connection, you should use the TUniConnection.OnConnectionLost event handler. The OnConnectionLost event handler is used to process fatal errors and perform failover. To make the OnConnectionLost event handler work, you should set the TUniConnection.Options.LocalFailover property to True. Note that to use the OnConnectionLost event handler, you should add the MemData unit to the USES clause of your unit. Here is an example of using the OnConnectionLost event handler:
Code: Select all
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
UniConnection1.Options.LocalFailover := True;
UniConnection1.Open;
end;
procedure TForm1.UniConnection1ConnectionLost(Sender: TObject;
Component: TComponent; ConnLostCause: TConnLostCause;
var RetryMode: TRetryMode);
begin
RetryMode := rmReconnectExecute;
end;