Connection Steps For DB2 Database with GenRocket Runtime

Step 1: Download DB2 JDBC Driver and place it in the $GENROCKET_HOME/lib/ folder

The IBM Data Server Driver for JDBC and SQLJ package includes two JDBC drivers:

  1. db2jcc.jar - This driver is based on the JDBC 3 specification
    1. 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.

  2. db2jcc4.jar - This driver is based on the JDBC 4 or later specifications

You can download both of these jars at this IBM website. After you download the appropriate jars for your DB2 instance, place them in your genrocket-3.5.12/lib folder. 

  • It is OK if your GenRocket version doesn't match the one above -- still just place the IBM Connector in the lib directory

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: Next step is to add a new resource named resource.jdbc.config in GenRocket Web

The resource.jdbc.config resource in this image points to the dev folder. 

  • Set the value of resource variable to the config file name with the full file path.
  • For example, say you have added at location /home/user/Desktop/. Then the resource value will be /home/user/Desktop/
  • Make sure to update your Profile (in ~/.genrocket folder) on your system after adding the new resource with its value. GenRocket will read this resource value from your profile on your system to make a connection with the database. 

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

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