Building an Application in Bluemix That Accesses Mainframe Data

Share this post:

This is part 4 of a five-part series on accessing mainframe data from your Bluemix applications.

If you have not yet read part 1, part 2, and part 3 of this series, please review them before proceeding further.

At this point, you (or a system programmer) have installed the Rocket Mainframe Data Service on your mainframe and mapped some VSAM data on the mainframe to a virtual table. You are now ready to access the data from the Bluemix app and build a cloud or mobile app in Bluemix that will utilize the mainframe data for real time access to the all useful Systems of Record.

Before we jump into app development, there is one other point that may impact you. If you are not using Bluemix Local or Bluemix Dedicated, you will need to setup a secure gateway via Bluemix to allow access to the Rocket Mainframe Data Service running on your mainframe. In the secure gateway setup, you should setup a destination with the appropriate host for your mainframe and the correct port for MongoDB access. For a brief introduction, see Bluemix Secure Gateway: Yes, you CAN get there from here!; see Reaching enterprise backend with Bluemix Secure Gateway for more details and setup instructions. The Rocket Mainframe Data Service looks exactly like MySQL or MongoDB to the Secure Gateway client, so you can set it up as if you were setting up a MySQL server or MongoDB server running on-premise.

In this article, we will walk through building an app in Bluemix and configuring the Rocket Mainframe Data service. Optionally, see Develop and deploy a Node.js app for guidance on setting up with the DevOps environment. After you are set up with your Node.js app in Bluemix as shown in the preceding article, you can add the service Rocket Mainframe Data to your app. When you click on the tile for Rocket Mainframe Data to add that service, it will prompt you for a connection string; you can retrieve it by filling out the form Rocket Mainframe Data Service Connection String ( above the connection string prompt in the Bluemix console. You can always type it yourself as well (it is a standard JDBC or MongoDB URI). Once you have entered the right information and the connection string is displayed, copy it and paste it in the Bluemix service provisioning dialog. This connection string will become available in your app for establishing connections.

In your app, you can use the following code to load the connection string:

if (process.env.VCAP_SERVICES) {
var envURI_UP = JSON.parse(process.env.VCAP_SERVICES);
dbURI = envURI_UP['user-provided'][0].credentials.connectionstring;
console.log("ENV VARIABLE: " + dbURI);

The rest of the code is standard JavaScript code to access MongoDB data. This is why this is such a powerful service. A JavaScript developer who is used to accessing MongoDB APIs will no longer have to worry about data formats and/or languages for the mainframe. He or she will simply access it as if it was MongoDB. Below is a snippet for establishing a MongoDB connection:

mongonative.connect(dbURI, function(err, db) {
assert.equal(null, err);
console.log("successfully connected with native mongodb driver for mainframe");

Accessing data is a matter of simply executing a query – just like you would against any other MongoDB database:

var collection = db.collection('vsam_staff');
collection.find({}).toArray(function (err, docs) {

It couldn’t be simpler. We are looking forward to the amazing apps that you will create now that you are able to access the critical Systems of Record with the same ease that you are used to with your Systems of Engagement.

In the next article, we will recount a story about building an IT operational analytics dashboard using Bluemix as the platform and Rocket Mainframe Data as the source. It truly demonstrates the power of Rocket Mainframe Data and Bluemix together. Stay tuned…

More stories
May 1, 2019

Two Tutorials: Plan, Create, and Update Deployment Environments with Terraform

Multiple environments are pretty common in a project when building a solution. They support the different phases of the development cycle and the slight differences between the environments, like capacity, networking, credentials, and log verbosity. These two tutorials will show you how to manage the environments with Terraform.

Continue reading

April 29, 2019

Transforming Customer Experiences with AI Services (Part 1)

This is an experience from a recent customer engagement on transcribing customer conversations using IBM Watson AI services.

Continue reading

April 26, 2019

Analyze Logs and Monitor the Health of a Kubernetes Application with LogDNA and Sysdig

This post is an excerpt from a tutorial that shows how the IBM Log Analysis with LogDNA service can be used to configure and access logs of a Kubernetes application that is deployed on IBM Cloud.

Continue reading