Working with JDBC to access mainframe data

Using Rocket DV virtual tables or virtual collections, enables you to now generate the code that is used to access the data on the mainframe. Rocket DV comes with a JDBC Type 4 driver that enables direct, real-time access to a variety of mainframe databases and file structures. Below is a Java code sample that you can use as a base to develop your JDBC application

//Sample Java class using JDBC Driver
* * This class contains methods and functions which connect to and interact with Rocket Data Virtualization.

package com.mycompany.samples;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class AccessMainframe {
               static Connection connection = null;

               //includes all info to connect to DVS
               private static boolean connectToDatabase(){
   //sample JDBC url, adjust accordingly and refer to JDBC guide for other connection settings
                              final String url = "jdbc:rs:dv://host:port; DBTY=DVS";
                              final String username = "myuser";
                              final String password = "mypwd"; 

                              System.out.println("Connecting to DVS...");

                              try {
                                             connection = DriverManager.getConnection(url, username, password);
                                             System.out.println("Connected to DVS"); 
                                             return false; 
                              } catch (SQLException e) { 
                                                                                          throw new IllegalStateException("Cannot connect the DVS", e); 

               //returns a result set from a given query
               public static ResultSet runQuery(String query){
                              //sample SMF records query="SELECT SMF30DDN,SMF30DCT FROM SMF_03000_SMF30EXP LIMIT 400";
                              if(connection == null){
                              while(connection == null);
                              Statement stmt = null;
                              try {
                                             stmt = connection.createStatement();
                              } catch (SQLException e) {
                                             throw new IllegalStateException("Cannot create statement", e);
                              ResultSet rs = null;

                              try {
                                             rs = stmt.executeQuery(query);
                              } catch (SQLException e) {
                                                            throw new IllegalStateException("Cannot create ResultSet", e);
                              return rs;             


Working with NoSQL and MongoDB

Your development environment might utilize a NoSQL database, something like MongoDB. With Rocket Data Virtualization any MongoDB compliant driver can be used for direct, real-time access to a wide variety of mainframe databases and file structures. In this case, we are providing a sample in JavaScript code using the Node.js framework.

// app.js
// This file contains the server side JavaScript code for your application.
// This sample application uses express as web application framework (,
// and jade as template engine (

var express = require('express');
var mongo = require('mongodb');

var mongonative = require('mongodb').MongoClient,
   assert = require('assert');

var dbURI = "mongodb://host:port/DVS";

// setup middleware
var app = express();
app.use(express.static(__dirname + '/public')); //setup static public directory
app.set('view engine', 'jade');
app.set('views', __dirname + '/views'); //optional since express defaults to CWD/views

// render index page
app.get('/', function(req, res){

mongonative.connect(dbURI, function(err, db) {
               console.log("Connect to DVS with native mongodb driver");
   assert.equal(null, err);
   app.get('/docs', function(req, res) {
   //DVS_collection_name- use one of the virtual table names from NoSQL node in Data Virtualization Studio        
    var collection = db.collection('DVS_collection_name');
     if(err) throw err;

Join The Discussion

Your email address will not be published. Required fields are marked *