Install an IBM DB2 client on the ArcGIS client machine and connect to the database from the ArcGIS client. 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.
To use your DB2 data in services published to ArcGIS Server, you must also register the database with ArcGIS Server.
Connect from ArcGIS for Desktop
To connect to a database or geodatabase in DB2 from ArcGIS for Desktop, install a DB2 client on the ArcGIS for Desktop 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 for Server. 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
A DB2 client must be installed on any computer that will connect to a DB2 database.
You can use your own DB2 client installation, or download the IBM Data Server Run-time 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 the database
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 ArcGIS for Desktop.
- 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 Datasource text box. If the database (or database subsystem) is not cataloged, you can 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 to 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 database 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 Preparing resources for publishing as services for more information about sharing a connection file.
Connect to a specific version
You are connected to the DEFAULT version when you initially connect to the geodatabase using the Database Connection dialog box. If you use geodatabase versioning and want to connect to a different transactional or historical version, use the Geodatabase Connection Properties dialog box. For more information, see Connect to a specific geodatabase version.
Connect from ArcGIS for Server
If DB2 and ArcGIS for Server are running on separate servers, install a DB2 client on the ArcGIS for Server computer.
If ArcGIS for Server is installed on a Linux server, edit the init_user_param.sh script to include information about the DB2 client and instance and restart ArcGIS for 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 ArcGIS Server. 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 for Server is installed on a different server than the DB2 database, install a DB2 client on the ArcGIS for Server machine.
You can use your own DB2 client installation, or download the IBM Data Server Run-time 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 to reference them. You can access this script by navigating to the <ArcGIS Server installation directory>/arcgis/server/usr directory.
- Ensure that the ArcGIS Server installation owner 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.
- Restart each GIS server in your ArcGIS Server deployment by running the startserver.sh script.
./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 ArcGIS Server. 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 ArcGIS Server. See About registering your data with the server for information on registration options and links to topics with instructions for registering your database.