Connection parameters in database specification

For development or testing purpose, connection parameters can be provided in the database specification string passed to the DATABASE and CONNECT TO instructions. Do not hard code connection specification parameters in programs to be installed on a production site, use the indirect database specification method instead, or build the connection string at runtime, to keep the database connection flexible.

The connection specification parameters override the dbi.database connection parameters defined in FGLPROFILE.

A + plus sign in the database specification starts the list of connection parameters. Each parameter is defined with a name followed by an equal sign an a value enclosed in single quotes. Connection specification parameters must be separated by a comma:

dbname+parameter='value'[,...]

In this syntax, parameter can be one of the following:

Table 1. Connection parameters in the database specification string
Parameter Description
resource

Specifies which 'dbi.database' entries have to be read from the FGLPROFILE configuration file.

When this property is set, the database interface reads dbi.database.name.* entries, where name is the value specified for the resource parameter.

driver

Defines the database driver library to be loaded (filename without extension).

source

Specifies the data source of the database.

username

Defines the name of the database user.

password

Defines the password of the database user.

Important: Do not write clear user passwords in your sources! This parameter should be set from a variable value.

In the next example, driver, source and resource are specified in the connection string:

MAIN
  DEFINE db CHAR(50)
  LET db = "stores+driver='dbmora',source='orcl',resource='myconfig'"
  DATABASE db
  ...
END MAIN