You can connect to DB2 from ArcGIS clients. To do so, install an IBM 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 connection file. To use your DB2 data in services published to an ArcGIS Server site, register the database or geodatabase with the site.
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 DB2 from 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.
- Ensure that the ArcGIS Server installation owner on each machine has at least read and execute permissions on the database client libraries.
- Open the init_user_param.sh script in a text editor.
- 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
- 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
- Save and close the script.
- After you have configured the init_user_param.sh on each machine in your ArcGIS Server site, run the startserver.sh script 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 sites. For geodatabases in DB2, you have two registration options. See About registering your data with ArcGIS Server for information on registration options and links to topics with instructions for registering your database or geodatabase.
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 DB2 from 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.
- Expand Database Connections in the Catalog tree in ArcMap or ArcCatalog and double-click Add Database Connection.
- 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.
- 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;
- 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. Also note that Save user name and password must be checked for connection files that provide ArcGIS services with access to the database or geodatabase or if you want to use the Catalog search 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:
- Click OK to connect.
A file is created in \\<computer_name>\Users\<user_name>\AppData\Roaming\ESRI\Desktop<release#>\ArcCatalog. If you encounter any problems with the connection, check the sdedc_DB2.log file in the %TEMP% directory for extended error messages.
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.
(Geodatabase only) Connect to a specific geodatabase version
When you initially connect to a geodatabase in DB2, you connect to the Default version using the Database Connection dialog box. If you use geodatabase versioning and want to connect to a different transactional or historical version, change versions using the Geodatabase Connection Properties dialog box. For more information, see Connect to a specific geodatabase version.
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.
- Right-click Databases in the Catalog pane and click New Database Connection.
- Choose DB2 from the Database Platform drop-down list.
- 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;
- 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. Also note that Save user name and password must be checked for connection files that provide ArcGIS services with access to the database or geodatabase or if you want to use search to locate data accessed through this connection file.
- Click OK to connect.