Connect to Db2 from ArcGIS

To connect to IBM Db2 from ArcGIS clients, install a Db2 client on the ArcGIS client machine. You can configure a data source name for the Db2 database and use that to connect from ArcGIS clients, or you can use a DSNless connection string to connect.

Once the client is configured, create a database connection file. To publish Db2 data to an ArcGIS Server site, register the database connection file with the site.

Connect from ArcGIS Pro

To connect from an ArcGIS Pro project to Db2, install a Db2 client on the ArcGIS Pro machine and create a database connection.

Configure a data source name (optional)

You can catalog a Db2 database, thereby creating a data source name (DSN) to be used when you connect to Db2 from ArcGIS. Follow the instructions on the IBM Db2 Information Center to catalog a Db2 database.

If you do not set up a data source name, you can connect from ArcGIS clients using a string that contains all the information the client needs to connect to your database. The string is in the format HostName=<DB2 host>;Port=<port number>;Database=<database name>. This type of connection string is called a DSNless connection.

Install the Db2 client

Install a Db2 client on any computer that will connect to a Db2 database.

You can use your own Db2 client installation or download the 64-bit IBM Data Server Runtime Client for Db2from My Esri.

Follow the instructions provided with the Db2 client software to install it.

Connect to the database

Add a database connection using the Database Connection dialog box or the Create Database Connection tool. The following steps describe using the Database Connection dialog box.

  1. Right-click Databases in the Catalog pane and click New Database Connection.
  2. Choose DB2 from the Database Platform drop-down list.
  3. Type the data source name in the Data source text box. If the database is not cataloged, use the following syntax to connect instead:

    HostName=<host>;Port=<port number>;Database=<database name>;

    Specify the information appropriate for your site.

    For example, if your Db2 database is on server cube, communicating through DBMS port 50000, and the database name is spatialdata, the connection string would be as follows:

    HostName=cube;Port=50000;Database=spatialdata;

  4. Choose the type of authentication to use when connecting to the database: Database authentication or Operating system authentication.
    • If you choose Operating system authentication, you do not need to type a user name and password—the connection is made using the login name and password used to log in to the operating system. If the login used for the operating system is not a valid database login, the connection fails.
    • If you choose Database authentication, you must provide a valid user name and password in the User name and Password text boxes, respectively. User names can be a maximum of 30 characters.

      Uncheck Save user name and password if you prefer not to save your login information as part of the connection; doing this can help maintain the security of the database. However, if you do this, you will be prompted to provide a user name and password every time you connect.

    Note:

    Save user name and password must be checked for connection files that use database authentication to provide ArcGIS web services with access to the database, or if you want to search ArcGIS Pro to locate data accessed through this connection file.

  5. Click OK to connect.

Connect from ArcGIS Server

If Db2 and your portal's federated ArcGIS Server sites are running on separate servers, install a Db2 client on all machines in each of the federated server sites.

If ArcGIS Server is installed on Linux servers, edit the init_user_param.sh script installed with ArcGIS Server to include information about the Db2 client and instance, and restart ArcGIS Server.

If you want the services you publish to your portal's federated servers to use the data in your database or geodatabase in Db2 without copying data, you must register the database with the federated server sites. You can use a data source name when registering the database—in which case you must catalog the database before registering—or you can provide a string of connection information (referred to as a DSNless connection).

Install the Db2 client

If ArcGIS Server is installed on a different server than the Db2 database, install a Db2 client on each machine in the ArcGIS Server site.

You can use your own Db2 client installation or download the IBM Data Server Runtime Client for Db2from My Esri.

Follow the instructions provided with the Db2 client software to install it.

Alter the init_user_param.sh script (Linux only)

Once you have installed the database client files, alter the init_user_param.sh script installed with ArcGIS Server to reference the client files. You can access this script by browsing to the <ArcGIS Server installation directory>/arcgis/server/usr directory.

Note:

If your user profile references the Db2 client and the client information differs between the user profile and init_user_param.sh, ArcGIS Server may experience problems when attempting to connect to the database. To alleviate connection issues, remove the reference information from your user profile and reference your database client libraries again using the following steps:

  1. Ensure that the ArcGIS Server installation owner on each machine has at least read and execute permissions on the database client libraries.
  2. Open the init_user_param.sh script in a text editor.
  3. Remove the comment marks (#) from the lines beginning with export.

    #
    # To connect to Db2
    export DB2_CLIENT_HOME=<DB2_InstallDir>
    export DB2INSTANCE=<DB2_instance_name>
    export PATH=DB2_CLIENT_HOME/bin:$PATH
    export LD_LIBRARY_PATH=$DB2_CLIENT_HOME/lib64:$LD_LIBRARY_PATH

  4. Replace <DB2_InstallDir> with the location of the Db2 client installation directory, and replace <DB2_instance_name> with the name of your Db2 instance.

    For example, if the Db2 client is installed to /home/db2prod and the Db2 instance is named db2prod, the file would look as follows:

    #
    # To connect to Db2
    export DB2_CLIENT_HOME=/home/db2prod
    export DB2INSTANCE=db2prod
    export PATH=DB2_CLIENT_HOME/bin:$PATH
    export LD_LIBRARY_PATH=$DB2_CLIENT_HOME/lib64:$LD_LIBRARY_PATH
  5. Save and close the script.
  6. After you have configured the init_user_param.sh on each machine in your ArcGIS Server site, run the startserver.sh script on each machine to restart ArcGIS Server.

    ./startserver.sh

Configure a data source name (optional)

You can catalog a Db2 database, thereby creating a data source name to be used when you register your database with an ArcGIS Server site. Be aware that if ArcGIS Server is installed on a Linux machine that is separate from the Db2 server, you must create a Db2 client instance on the client machine before you can catalog the Db2 database.

Register the database

If you want your web services to use the data in your database or a geodatabase in Db2, register it with your ArcGIS Server site. See Manage registered data stores for instructions.