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 ArcGIS client machines, create a database connection file. 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.
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.
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.
Connect to the database
Add a database connection using the Database Connection dialog box or the Create Database Connection geoprocessing tool.
Follow the steps below to connect to a Db2 database using the Database Connection dialog box in ArcGIS Pro.
- Open the Catalog pane in ArcGIS Pro.
- Right-click Databases 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 host, port, and database name appropriate for your connection.
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;
After you validate the connection or create the database connection file, the port number and database name will appear under Additional Properties.
- 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 username and password—the connection is made using the login name and password used to sign 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 username and password in the User name and Password text boxes, respectively. Usernames 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 username 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 and to search ArcGIS Pro to locate data accessed through this connection file.
- Type a name for the connection file in the Connection File Name field.
As you provide connection information, a default name is created. You can use the default, or type a more descriptive file name.
This is the name that will appear in the Catalog pane and view, and the name of the .sde file stored on disk.
- Click Validate to confirm that the connection information is valid and the database is accessible.
If the database contains a geodatabase and the connection is valid, the Geodatabase Properties tab is now active. If necessary, you can alter geodatabase connection properties to connect to a traditional version other than the default version, configure the connection as a branch version connection, or connect to a historical moment.
- Click OK to create the connection file.
A database connection appears under Databases in the Catalog pane, and a connection file (.sde) is created in the ArcGIS Pro project directory.
Connect from ArcGIS Server
If Db2 and the ArcGIS Server site to which you want to publish are running on separate servers, install a Db2 client on all machines in the ArcGIS Server site.
To publish web services that use the data in the Db2 database or geodatabase in Db2 without copying data, 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
Install the 64-bit Db2 client on all ArcGIS machines that need to connect to a Db2 database. You can obtain Db2 client files from IBM or from My Esri. Follow the instructions provided with the Db2 client software to install it. If you do not have the privileges necessary to install software on the machines where ArcGIS clients are running, you'll need to have your IT department install the Db2 client for you.
Configure a data source name (optional)
After you install the Db2 client software, 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.
If you choose not to catalog a database, you must specify a DSNless connection string to connect to a Db2 database in the form HostName=<host>;Port=<port number>;Database=<database name>;. See Database connections in ArcGIS Pro for more information and an example.
Create a database connection file
Create a database connection file using the Database Connection dialog box in ArcGIS Pro, as described above.
Alternatively, you can run the Create Database Connection tool in ArcGIS Pro or use Python to run the Create Database Connection command from an ArcGIS Server machine to create a database connection file (.sde) that connects to the database.
The following information is specific to creating a database connection file for use with ArcGIS Server:
- You must save database-authenticated user information with the connection file.
- If you use operating system authentication to connect, ensure your Db2 server can authenticate the ArcGIS Server account.
Grant privileges
The login used to connect to the database must have specific privileges granted to it. For logins that will only publish read-only services (such as map services), grant the privileges necessary for a data viewer, as described in Privileges for geodatabases in Db2 or Privileges for using ArcGIS with a Db2 database. For logins that will publish editable feature services, grant the privileges necessary for a data editor. If you will be registering the geodatabase as a managed database, grant the privileges necessary for a data creator.
If your connection to Db2 uses operating system authentication, grant the appropriate privileges to the ArcGIS Server account.
If the data is in a geodatabase, the data owner must grant the required privileges to the data. If the data is in a database, the data owner can grant privileges from ArcGIS or the database administrator can use database tools to grant the required privileges.
Register the database
If you want your web services to use the data in the Db2 database or a geodatabase in the Db2 database, register the database connection file with the ArcGIS Server site.
You can use the database connection file you created to register the database with ArcGIS Server from the Manage registered data stores pane in ArcGIS Pro or from ArcGIS Server Manager.