SQL connection identifier
Database client programs can be identified by name with some database server types.
Purpose of SQL connection identifiers
When connecting to databases such as PostgreSQL or SQL Server, it is possible to define a name for the database client program.
This allows for the association of a name with a database client connection in the database server, to be used in logging and trace utilities.
For example, if you don't define the application identifier for SQL Server client programs, all connections will get the name "ODBC".
SQL application identifier with SQL Server
The SQL Server client application identifier can be defined by using the
APP=name
ODBC connection string parameter. The ODBC application
identifier will be available in the SQL Server session with sp_who
and
APP_NAME()
SQL functions. This name will also be visible in the
"ApplicationName"
column of SQL Profiler trace logs.
To pass ODBC connection string parameters to SQL Server, use the
?options
notation in the "source"
connection
parameter.
With an FGLPROFILE entry:
dbi.database.mydb.source = "mydatasource?APP=myappid;"
At runtime with connection parameters in database specification:
CONNECT TO "mydb+source='mydatasource?APP=myappid;'" USER un USING up
ODBC connection string parameters must be terminated by a ;
semi-colon.
SQL application identifier with PostgreSQL
The PostgreSQL client application identifier can be defined with the
application_name
PostgreSQL URL connection string parameter.
To pass URL connection string parameters to PostgreSQL, use the
?options
notation in the "source"
connection
parameter:
With an FGLPROFILE entry:
dbi.database.mydb.source = "mydatabase?application_name=myappid"
At runtime with connection parameters in database specification:
CONNECT TO "mydb+source='mydatabase?application_name=myappid'" USER un USING up
PostgreSQL URL connection string parameters must be separated by a &
ampersand.