Connection Steps For DB2 Database with GenRocket Runtime

There can be two primary reasons for you to make a connection with a DB2 database with GenRocket:

  • Reason 1: To retrieve data from the database while generating data using GenRocket runtime using generators like ListQueryGen, QueryBeforeLoop, etc.

  • Reason 2: To populate tables in the database using receivers like GenericSQLInsertReceiver, SQLUpdateReceiver, etc.

To use these Generators and Receivers, GenRocket leverages JDBC.

In This Article

What is JDBC?

JDBC stands for Java™ database connectivity (JDBC) and is the JavaSoft specification of a standard application programming interface (API) that allows Java programs to access database management systems. GenRocket can connect to any database that supports JDBC.

Connection Steps 

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.

Step 2: Create a JDBC Configuration Properties File

For GenRocket to connect to an DB2 database via JDBC you will need to create a file. Any application can connect a DB2 database via JDBC by reading a JDBC properties file that contains the following information:

  • driver - Defines the name of the specific database driver to use to access the given database.  The actual driver file must be placed in the $GEN_ROCKET_HOME/lib folder on your local computer. For DB2, the value should be
  • user - Defines the Username used to access the database.
  • password - Defines the password used to access the database.
  • url - Defines the specific URL to access the database. See more in this information below. 
  • batchCount - Defines the number of SQL statements that are batched together and sent to the database for execution.  This property is only mandatory for GenRocket Receivers.
url= jdbc:db2://<hostName>:<portNumber>/<databaseName>;<property=value>

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:

password= P@ssword1
url= jdbc:db2://localhost:50000/sampledb

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 datasource.
  • Property is one or more option connection properties.

Step 3: Enter a valid value for the resource.jdbc.config Organization Resource in GenRocket

The resource.jdbc.config Organization Resource specifies the location of the JDBC file on the logged in user's local machine. For more information about Organization Resources, click here.

This resource value should contain the full directory path (e.g., /home/user/dev)

Linux/Mac OSX Example

Windows Example

Step 4: Update your Profile in the .genrocket Folder

Each user has their own Profile that is stored in the .genrocket folder on their local machine. You will need to download and replace your profile (in ~/.genrocket folder) any time the following changes are made: 

  • Resource value(s) are updated
  • A new resource is added
  • A resource is removed

GenRocket will read this resource value from your profile on your system to make a connection with the database. 

Step 5: Reference the JDBC Resource in your Generators or Receivers

When you create a Scenario with a Generator or Receiver that references your jdbc.config resource, it will connect directly to your database. 


If you cannot connect to your IBM DB2 database via JDBC, please get in touch with us at