Got a DB2 database that needs a REST API? Now you can connect to your IBM DB2 with DreamFactory in just a few minutes. In this short blog post I’ll explain how to connect to DB2 and use DreamFactory’s auto-generated REST API for DB2.

Step 1 – Get DreamFactory Up and Running

If you haven’t done so already, either sign up for a free hosted DreamFactory account or install DreamFactory on your local computer or on a server. The easiest way to install DreamFactory is to use a Bitnami installer for Windows, Linux, VMware, or a cloud server (AWS, Microsoft Azure, or Google Cloud Platform).

Note: Connecting to DB2 from a DreamFactory install on Mac OS X isn’t currently supported.

Step 2 – Configure the DB2 Driver

If you’re using a hosted DreamFactory account, you can skip this step and go directly to Step 3.

If you’ve installed DreamFactory, follow the instructions below to configure the DB2 driver. These instructions assume you’ve installed DreamFactory with one of the DreamFactory Bitnami installers.

  1. Download, unpack, and run the installer for the PDO_IBM driver module. Download links and instructions for Linux and Windows are here.
  2. Add the unpacked driver path to Bitnami’s file.
  3. Navigate to the php.ini file located at /opt/bitnami/php/etc/php.ini and open the file. For Windows, uncomment this line: extension=php_pdo_ibm.dll. For Linux, uncomment this line: (Note: If you don’t see this line in php.ini, add it to the php.ini file and save the file).
  4. Restart the Bitnami server.

Step 3 – Connect to Your DB2 Database

Now it’s time to connect to your DB2 database. Log into your DreamFactory Admin Console as an Administrator and navigate to the ‘Services’ tab. Click to create a new service, select ‘Remote SQL DB’, and fill out the required information, including host, database name, username, and password. Then click to save the connection.


Step 4 – Browse the REST API for DB2

After you’ve successfully connected to your DB2 database, click on the ‘API Docs’ tab in the DreamFactory Admin Console. In the list of APIs you’ll see an API for DB2 with whatever name you entered above in Step 3, in my example ‘DB2’.

Click around to browse the DB2 API. You can click on any of the HTTP verbs, look at the parameters for a particular API call, and click the ‘Try it out!’ button to make live API calls to your DB2 database.


The DB2 API supports a bunch of powerful features, including:

  • Master Credentials – Master credentials for your remote DB2 database are encrypted in DreamFactory.
  • Data Security – The permissions granted by the DB2 credentials you specify are honored by the REST API.
  • Query Filters – Pass in filter strings as an API parameter with any number of AND / OR logical operations.
  • Related Objects – The API can return an array of objects and related objects in a sub-array with a single API call.
  • Stored Procedures and Views – Call DB2 stored procedures and views.
  • Paging and Sorting – Use URL parameters to limit and sort records returned to the client .
  • Continue or Rollback – The API provides parameters to continue processing an array of objects in spite of errors, or to rollback the entire operation if any error is encountered.
  • Schema Support – The API can return information about what tables are available, as well as access rights for each table and field.
  • Lookup Keys – The API can inherit the same permissions on the remote DB2 database, based on user roles.
  • Record-Level Access – DreamFactory enables fine-grained control of records inside a given table.

Once you’re familiar with the DB2 API, it’s time to build an application! You can call the API just as you would any REST API or use one of our client SDKs to help accelerate your development and simplify your code.

As always, please let us know what you think in the comments. And if you need help or have questions, head on over to the forum or contact [email protected].