Auto Reconnect

The SQL drivers have the ability to automatically reconnect after a lost connection.

A lost connection situation happens if for some reason the connection between a workstation and the database server has been lost.  

A lost connection can be caused for several reasons:


Reconnect Logic

The drivers will try to re-connect to the database server when a connection lost error has been received.  



After a successful reconnection inside a Find operation, it will appear to the program as if nothing has happened. The program has executed a successful Find operation and is unaware a re-connect has taken place. Note that this will only occur if the first re-connect attempt is successful.

If the first reconnect attempt fails, the Find operation will generate a ‘connection lost’ error.  The next Find operation from the program will again try to reconnect.

After receiving a connection lost error, the driver will not try to reconnect when it is inside a transaction. Instead it will generate ’lost connection’ error. This will abort and roll back the transaction. The first operation after the transaction will try to reconnect, and, if successful, the program can continue.

Re-executing the operation after a successful reconnect will only be done on Find and Open operations.

Save and Delete operations always take place inside a transaction and will not try to reconnected, but generate an error that will cause a transaction abort.

Configure Auto Reconnect

Auto Reconnect can be configured in the driver configuration file (MSSQLDRV.INT, DB2_DRV.INT or ODBC_DRV.INT) with the following keyword:


The default value is 1 (Auto-Reconnect On)


Connection Lost Error

The driver will generate the following error when the connection to the database was lost:


Connection to database lost

The driver will translate the database native connection lost errors to this DataFlex error code.

For the SQL Server and DB2 drivers, the native connection lost errors are pre-configured and don't have to be setup.

The ODBC driver can connect to different database back ends and the connection lost state(s) must be specified in the database specific configuration file like,,, etc.

The connection lost state can be specified with the CONNECTION_LOST_STATE keyword. If there are multiple connection lost states, the CONNECTION_LOST_STATE keyword can be specified multiple times.

Example (MySQL.INT)

; Connection_Lost_State

;   The native error that indicates a lost connection.

;   This error will translate to a DF lost connection error.

Connection_Lost_State 08S01


See Also

Connectivity Concepts