API:FireDAC.Comp.Client.TFDConnection.OnRecover

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

property OnRecover: TFDConnectionRecoverEvent read FOnRecover write FOnRecover;

C++

__property OnRecover;

Properties

Type Visibility Source Unit Parent
event published
FireDAC.Comp.Client.pas
FireDAC.Comp.Client.hpp
FireDAC.Comp.Client TFDConnection

Description

Occurs when the connection to the DBMS is lost.

FireDAC.Comp.Client.TFDConnection.OnRecover inherits from FireDAC.Comp.Client.TFDCustomConnection.OnRecover. All content below this line refers to FireDAC.Comp.Client.TFDCustomConnection.OnRecover.

Occurs when the connection to the DBMS is lost.

The event handler of OnRecover receives the following parameters:

  • ASender is the connection.
  • AInitiator is the object that discovers that the connection has been lost.
  • AException is the exception that describes the issue that occurred.
  • AAction determines the action that FireDAC must take to handle this issue.

You can handle OnRecover to analyze the cause of the issue and determine how FireDAC must handle the issue. To determine how FireDAC must handle the issue, change the value of AAction to any of the following values:

Action Description

faDefault
(default)

If ResourceOptions.AutoReconnect is True, try to reconnect.
If ResourceOptions.AutoReconnect is False (default), close the connection and raise AException.

faFail

Close the connection and raise AException.

faRetry

Try to reconnect.

faCloseAbort

Close the connection and abort the current operation.

faOfflineAbort

Switch the connection to the offline mode and abort the current operation.

To have FireDAC retry the connection, do either of the following:

If you have FireDAC retry the connection, FireDAC retries the connection up to 3 times. After 3 failed connection attempts, FireDAC closes the connection and raises AException.

See Also