Learn about automatic database reconnect
- Last Updated: February 11, 2026
- 7 minute read
- OpenEdge
- Version 13.0
- Documentation
OpenEdge provides a mechanism for automatically connecting to an alternate database, if the connection to the primary database fails. This high-availability feature uses database connection parameters to specify alternates and can be used anywhere database connection parameters are allowed. The collection of primary and alternate databases, along with an optional retry count and pause interval, is known as a connection set. An alternate database is typically a replication target database, but it could also be a backup, or some other database. This feature is only available when using a client-server connection. It is not available for a single-user or a self-service (shared-memory) connection.
To use this feature, you define a connection set consisting of the
primary database and up to two alternate databases. You can also specify the number of
times to retry the connection set and a pause interval for waiting in between. These
connection options are implemented using parameters. The parameters can be defined as
session startup parameters, in the CONNECT statement,
or in a parameter file ( .pf ).
For a demo of this feature, see Automatic database reconnect demo and code.
Use database connection parameters to enable feature
The database connection parameters that
can be used to enable this feature are: -dbalt1,
-dbalt2, -retryConnect, -retryConnectPause
and -autoReconnect. -dbalt1 and -dbalt2 are parameters
that specify connection information (database name, host, and port) about the
alternate databases. If you only have one alternate you need only use one of these
parameters. -retryConnect specifies the number of
retry attempts allowed for the connection set as a whole, before giving up. -retryConnectPause specifies the time to wait, in
seconds, before retrying the connection set. -autoReconnect applies to GUI or character-mode clients and indicates
that if an unhandled STOP condition occurs, you want to try reconnecting databases
connected using startup parameters before rerunning the -p procedure. -autoReconnect is also
used with OpenEdge replication, to automatically include the OpenEdge replication
primary target database in the connection set. The syntax for each parameter is
described below.
-
-dbalt1— The first alternate database to attempt to connect to.-dbalt1 "dbname [-H hostname] -S port"If hostname is not specified, localhost is used. All arguments for
-dbalt1must be enclosed in quotes.-Hand-Sare the only arguments allowed. -
-dbalt2— The second alternate database to attempt to connect to.-dbalt2 "dbname [-H hostname] -S port"If hostname is not specified, localhost is used. All arguments for
-dbalt2must be enclosed in quotes.-Hand-Sare the only arguments allowed. -
-retryConnect— The number of times to retry the connection set before giving up.-retryConnect retry-countAll connections in the set (primary,
-dbalt1,-dbalt2) are tried in turn before retrying the set. The default value for retry-count is 0. The maximum value is 100. -
-retryConnectPause— The pause interval (in seconds) to wait before retrying the connection set.-retryConnectPause pause-intervalAll connections in the set (primary,
-dbalt1,-dbalt2) are tried in turn before the pause occurs. The default pause-interval is 5 seconds. The maximum value you can set is 300 seconds. -
-autoReconnect— For GUI or character-mode clients, indicates that if an unhandled STOP condition occurs, you want to try reconnecting databases connected using startup parameters before rerunning the startup procedure.-autoReconnectWhen running without
-autoReconnect, the ABL session is reset and and the startup procedure is run, without attempting to reconnect to any databases that were specified at startup using startup parameters.-autoReconnectis also used with OpenEdge replication, to automatically include the OpenEdge replication primary target database in the connection set.
-ct (Connection Retry Attempts) is
an independent, but related, startup parameter, which controls the number of
connection retries for an individual database connection.
The connection attempts are done in succession on the same database connection and
have a default value of 50 attempts. This differs from -retryConnect, which applies to the connection set as a whole. If
using both -ct and -retryConnect, you may want to set -ct to 0, or to a value lower than the default.
Database connection parameter considerations
- Like other database startup parameters,
-dbalt1,-dbalt2,-retryConnect, and-retryConnectPauseapply only to the last database parameter (-db) encountered in the parameter list thus far. - You must specify the primary database first, before listing an alternate, otherwise the AVM issues an error.
- If both
-dbalt1and-dbalt2are specified and the connection to the primary database fails,-dbalt1is tried first and-dbalt2is tried second. - If you only specify
-dbalt2, it becomes the first alternate. - If the AVM is unable to connect to any database the
CONNECTstatement goes through the usual error handling. - Any database parameters from the primary database, except for
-Hand-S, are also applied to the alternate databases, such as-ld,-Uand-P. - The logical name of the alternate database is always taken from
the primary database, even if not explicitly set with
-ld. - If the same parameter is encountered more than once within the
argument list for
-dbalt1or-dbalt2, the last one is used. This is consistent with the parsing rules for parameters in general. - If multiple
-dbalt1or-dbalt2parameters are encountered within the parameter list for a particular primary database, the last one is used.
Example configurations
Example: Specify a primary database with one alternate:
|
- Try to connect to mainDb.
- If that fails, it would try to connect to altDb.
- If that fails, it would pause 5 seconds (default for
-retryConnectPause) and repeat from step 1, three more times (because-retryConnectis 3).
Example: Specify a primary database with two alternates:
|
Example: Specify multiple primary databases with alternates:
|
Usage of parameters in the CONNECT statement
You may also use these database connection parameters in a CONNECT statement. For -dbalt1 and -dbalt2 each alternate
database name, along with its host and port parameters, must be enclosed in quotes.
In the following example, the arguments to -dbalt1
and -dbalt2 are surrounded by single quotes and
the connection string is surrounded by double quotes. You can reverse this and use
double quotes to surround the inner arguments and use single quotes for the outer
connection string.
In the following example code, one alternate database is specified:
|
The following example code assigns the connection string to a
CHARACTER variable. It uses single quotes to enclose the inner -dbalt1 parameters and double quotes for the outer
string:
|
The following example code specifies two alternate databases:
|
Automatic Database Reconnect with Progress Application Server (PAS) for OpenEdge sessions
The automatic restart behavior controlled by the -autoReconnect parameter does not apply to PAS for
OpenEdge sessions. To achieve this behavior with a PAS for OpenEdge session, create
a PAS for OpenEdge instance Activate procedure for connecting to
the database. The following example code is an Activate procedure called dbconnect.p:
|
You set the Activate procedure in the openedge.properties file. For example:
|
Enable logging for troubleshooting
The DB.Connects log entry type
(-logentrytypes DB.Connects) turns on logging
for database connections. (For information on configuring and enabling logging, see
Logging infrastructure overview in Troubleshoot ABL Applications.) Normally, connect and
disconnect messages are logged at the basic level (2 or higher). With this feature,
additional messages are logged if the initial attempt to connect to the primary
database fails. Consider the following connection string:
|
|
|
-retryConnectPause.
|
-autoReconnect is enabled, a message is
logged:
|
See also
Alternate Database 1 (-dbalt1)
Alternate Database 2 (-dbalt2)
Auto Reconnect (-autoReconnect)
Automatic database reconnection with OpenEdge replication
Connection Retry Attempts (-ct)