In This Article
- How to Connect to an IBM DB2 Database
- Step 1 - Download DB2 JDBC Driver and place in the $GENROCKET_HOME/lib/ folder
- Step 2 - Create a JDBC Config File (config.properties)
- Step 3 - (Optional) Encrypt the JDBC Config file
- Step 4 - Update Your JDBC Organization Resource Value
- Step 5 - Update your Profile in the .genrocket Folder
- Step 6 - Test the JDBC Connection
- Step 7 - Reference the JDBC Resource
- Troubleshooting
How to Connect to an IBM DB2 Database
Step 1 - Download DB2 JDBC Driver and place in the $GENROCKET_HOME/lib/ folder
The IBM Data Server Driver for JDBC and SQLJ package includes two JDBC drivers:
- db2jcc.jar - This driver is based on the JDBC 3 specification
- db2jcc4.jar - This driver is based on the JDBC 4 or later specifications
Note: The db2jcc.jar driver is now deprecated. After version 3.72, which is delivered with DB2 Version 11.1 for Linux, UNIX, and Windows Modification Pack 1 Fix Pack 1, db2jcc.jar will include no new features.
You can view all available downloads here: https://www.ibm.com/support/pages/db2-jdbc-driver-versions-and-downloads
Step 2 - Create a JDBC Config File (config.properties)
For GenRocket to connect to an IBM DB2 database via JDBC, you must create a JDBC Config or config.properties file. Any application can connect to an IBM DB2 database via JDBC using the information included in this file. Click here to learn more.
Template
driver=<JDBCDriverClassName>
user=<userToConnectToDatabase>
password=<passwordToConnectToDatabase>
url= jdbc:db2://<hostName>:<portNumber>/<databaseName>;<property=value>
batchCount=1000
Example
As an example, to connect to a DB2 database named sampledb and is configured to listen in the port 50000 with the user db2admin1 and password P@ssword1, the configuration file would be:
driver= com.ibm.db2.jcc.DB2Driver
user=db2admin1
password= P@ssword1
url= jdbc:db2://localhost:50000/sampledb
batchCount=1000
JDBC URL Explanation
The general form of the connection URL is jdbc:db2://[hostName[:portNumber]/[databaseName]][;property=value[;property=value]]
- jdbc:db2:// is known as the sub-protocol and is constant.
- hostName is the address of the server to connect to. This could be a DNS or IP address.
- portNumber is the port number of the database instance. The default is 50000.
- databaseName is the name of the data source.
- Property is one or more option connection properties.
Step 3 - (Optional) Encrypt the JDBC Config file
You can encrypt this file for additional security. Click here to learn more.
Step 4 - Update Your JDBC Organization Resource Value
The resource.jdbc.config Organization Resource specifies the location of the JDBC Config file on the logged in user's local machine. This resource value should contain the full directory path (e.g., /home/user/dev). Click here for more information.
Step 5 - Update your Profile in the .genrocket Folder
Each user has a profile stored in the .genrocket folder on their local machine. You must download and replace your profile (in ~/.genrocket folder). GenRocket will read this resource value from your profile on your system to make a connection with the database. Click here for more information.
Step 6 - Test the JDBC Connection
You can test the JDBC connection before referencing the resource in GenRocket. Click here to learn more.
Step 7 - Reference the JDBC Resource
When you create a Scenario containing a Generator or Receiver that references your jdbc.config resource, it will connect directly to your database. GenRocket feature that uses a database connection will also need to reference this file.
Troubleshooting
If you cannot connect to your IBM DB2 database via JDBC, please get in touch with us at support@genrocket.com.