Skip To Content

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 Db2 client is configured on all your ArcGIS client machines, create a database connection file in ArcGIS Pro or ArcMap. To publish ArcGIS Server web services that reference the data in your Db2 database, register the database connection file with your ArcGIS Server sites.

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 Db2 from 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 ArcMap

To connect to a database or geodatabase in Db2 from ArcMap, install a Db2 client on the ArcMap computer and create a connection file in the Catalog tree. You can use a data source name to connect—in which case you must catalog the database before creating the connection—or you can provide a string of connection information.

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 IBM Data Server Runtime Client for Db2from My Esri. If you are installing the client on a 64-bit operating system, run the 64-bit Db2 client executable; it installs both 32- and 64-bit files.

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

Connect to Db2

You can connect to a database or geodatabase in Db2 by adding a database connection under the Database Connections node in the Catalog tree in ArcMap or using the Create Database Connection tool. The following steps describe how to make a connection in the Catalog tree.

  1. Expand Database Connections in the Catalog tree in ArcMap or ArcCatalog and double-click Add Database Connection.
  2. If you are connecting to Db2 on a Linux, UNIX, or Windows server, choose DB2 from the Database Platform drop-down list. If you are connecting to Db2 on a z operating system (z/OS), choose DB2 for z/OS from the Database Platform drop-down list.
  3. Type the data source name in the Data source text box. If the database (or database subsystem) 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 from a desktop client.

    Note:

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

    In the following example, a connection is made to a cataloged database (spatialdata) in a Db2 instance using database authentication:

    Example Db2 connection using a cataloged database

  5. Click OK to connect.

A file is created in \\<computer_name>\Users\<user_name>\AppData\Roaming\ESRI\Desktop<release#>\ArcCatalog.

You can move the connection to another location; just be sure users and applications that need to make a connection have read access to the directory where you place the connection file.

If you use the data from this connection as the source for a service, such as a geoprocessing or geocoding service, you may need to place the connection file in a shared location on your network. See Make your data accessible to ArcGIS Server for more information about sharing a connection file.

Connect from ArcGIS Server

If Db2 and the ArcGIS Server to which you want to publish are running on separate servers, install a Db2 client on all machines in the ArcGIS Server site.

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 ArcGIS Server to use the data in your database or geodatabase in Db2, you must register the database with your ArcGIS 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 in the ArcGIS Pro help or Register your data with ArcGIS Server using Manager for instructions.

Note:

You cannot register Db2 on z Operating System databases with ArcGIS Server. Follow the instructions to create a service definition file, uncheck the option to Include data in service definition when publishing, and then publish the file to ArcGIS Server.