You can connect to IBM db2 using a Data Source or directly.
IBM db2 Data Source
Domino supports 2 different types of IBM db2 Data Sources.
The first type of db2 Data Source connects to db2 through Starburst JDBC connection. For this method, Your administrator must create a Data Source for this data store for you to use.
After your administrator has created the Data Source, you can work with it in your project as usual.
Additionally, Domino offers a native db2 Data Source type that directly connects to your db2 database without Starburst. This method is described below.
Create an IBM db2 tabular Data Source
-
From the navigation pane, click Data > Data Sources.
-
Click Create a Data Source.
-
In the New Data Source window, from Select Data Store, select DB2.
-
Enter the Host. Valid values are
<host string>:<port> or <host string>.
If no port is specified, the default is 50000.
-
Enter the name of the Database.
-
Enter the Data Source Name.
-
Optional: Enter a Description to explain the purpose of the Data Source to others.
-
Click Next.
-
Specify the credentials for authenticating to db2, only Basic authentication is supported
-
Select whether Everyone can access this Data Source or just Specific users or organizations.
-
Select who can view and use the Data Source in projects.
-
Click Finish Setup.
Direct connection
Connect directly to IBM db2 from Domino. You must have network connectivity between IBM db2 and your Domino deployment.
Domino does not officially support this method. We provide this information as a courtesy.
Python and ibm_DB2
Domino recommends the ibm_DB2 package for interacting with DB2 databases from Python.
Environment setup
Use the following Dockerfile instruction to add ibm_db to your environment.
This instruction assumes you already have pip installed.
RUN pip install ibm_db ibm_db_sa
Credential setup
Set the following Domino environment variables to store secure information about your DB2 connection.
See Store Project credentials to learn more about Domino environment variables.
Usage
See Python support for IBM Db2 for LUW, IBM Informix and IBM Db2 for z/OS for detailed information about how to use the package. The following is an example for connecting to DB2 with ibm_db where:
-
You have set up the environment variables with the
db_username and db_password.
-
You’ve replaced
my.host.name with the host name for your machine.
import ibm_db
import ibm_db_dbi
import pandas as pd
hostname = 'my.host.name'
port = 50001
username = os.environ['db_username']
password = os.environ['db_password']
def query_db(sql):
ibm_db_conn = ibm_db.connect("DATABASE=IBMPROD;HOSTNAME={};PORT={};PROTOCOL=TCPIP;UID={};PWD={};".format(hostname, port, username, password), "", "")
conn = ibm_db_dbi.Connection(ibm_db_conn)
df = pd.read_sql_query(sql, conn)
ibm_db.close(ibm_db_conn)
return df
sql_cmd = """
SELECT
*
FROM
table
"""
df_cmd = query_db(sql_cmd)
df_cmd
See Connecting to an IBM database server in Python.
R and ibmdbR
Domino recommends the imbdbR library for interacting with DB2 databases from R.
Environment setup
Use the following Dockerfile instruction to add ibmdbR to your environment.
RUN R -e 'install.packages("ibmdbR")'
Next steps