Setting the Microsoft SQL Server environment variables

The Microsoft SQL Server environment variables must be set in the db2dj.ini file on the federated server.

About this task

Restrictions

Review the restrictions for the db2dj.ini file before you begin this task.

The db2dj.ini file contains configuration information about the Microsoft SQL Server ODBC driver that is installed on your federated server.

There are required and optional environment variables for Microsoft SQL Server data sources.

If you installed the Microsoft SQL Server client software before you installed the Microsoft SQL Server wrapper, the required Microsoft SQL Server environment variables are set in the db2dj.ini file.

You must set the environment variables by using the steps in this task if you did not install the Microsoft SQL Server client software before you installed the Microsoft SQL Server wrapper or if you want to set any of the optional environment variables.

The following environment variables are valid for Microsoft SQL Server:
  • DJX_ODBC_LIBRARY_PATH
  • ODBCINI
DJX_ODBC_LIBRARY_PATH
Specifies the directory path to the ODBC library files.
For example:
DJX_ODBC_LIBRARY_PATH=ODBC_driver_directory/lib

ODBC_driver_directory is the directory path where the ODBC driver is installed.

Starting with Db2 V11.1.1.1, the SQL Server ODBC driver is bundled with the product installation package and the default lib path is set to: $INSTANSE_HOME/sqllib/federation/odbc/lib/. For Db2 11.1 GA version you can refer to this technote.

ODBCINI
Specifies the directory path where your ODBC configuration file (odbc.ini) is located.
For example:
ODBCINI=/home/db2inst1/odbc.ini

Do not set the ODBCINI environment variable as a system variable.

You can set the environment variables by using the steps in this task if you did not install the Microsoft SQL Server client software before you installed the Microsoft SQL Server wrapper or if you want to set any of the optional environment variables.

Procedure

  1. Edit the db2dj.ini file.
    • On federated servers that run UNIX, this file is located in the sqllib/cfg directory.
    • On federated servers that run Windows, this file is located in the %DB2PATH%\cfg directory.

    If the file does not exist, you can create a file with the name db2dj.ini by using any text editor. In the db2dj.ini file, you must specify the fully qualified path in the value of the environment variables; otherwise you will encounter errors.

    For example:
    DJX_ODBC_LIBRARY_PATH=/home/db2inst1/sqllib/federation/odbc/lib/ 
    ODBCINI=/home/db2inst1/sqllib/cfg/odbc.ini
  2. To ensure that the environment variables are set on the federated server, recycle the Db2® instance with these commands:
    db2stop 
    db2start

What to do next

After you complete this task, you can register the wrapper.