IBM Support

RFT and getConnection to DB2 database from the RFT perspective

Troubleshooting


Problem

Connecting to an IBM® DB2® Database from the IBM Rational Functional tester (RFT) perspective can hang if a Java™ test script makes calls to DB2, and DB2 is using a different Port than the JDBC driver.

Symptom

The RFT script which contains DB2 code hangs without any error message.

Cause

The hang can happen if a wrong port number or JDBC driver class is used in the RFT script.

Resolving The Problem

The DB2 database uses a different port number for a JDBC driver. You need to choose correct JDBC driver. The default port number for JDBC driver is 6789.

The JDBC driver library is db2java.zip. This library needs to be in the RFT project path and you must make sure that the db2java.zip file you are using is in synch with a DB2 database server (both should be on the same version). You can usually find a JDBC driver library in C:\Program Files\IBM\SQLLIB\java folder, if you have DB2 client installed.

Example code
To use this code in your RFT project, create an empty RFT script and add this code inside your class. Please make sure you adjust the URL in the code according to your environment details.


import java.sql.*;

import resources.DB2ConnectionHelper;
import com.rational.test.ft.*;
import com.rational.test.ft.object.interfaces.*;
import com.rational.test.ft.object.interfaces.siebel.*;
import com.rational.test.ft.script.*;
import com.rational.test.ft.value.*;
import com.rational.test.ft.vp.*;

public class DB2Connection extends DB2ConnectionHelper
{
public void testMain(Object[] args)
{
callDB2();
}

public void callDB2(){
Connection conn = null;
try {

DriverManager.registerDriver((Driver)Class.forName ("COM.ibm.db2.jdbc.net.DB2Driver").newInstance());

//DB2Driver
//localhost - host where DB is runing
//6789 is the default port number for JDBC driver to connect
//TESTMAN -  is database name
//administror - my user name for DB2
//Rationl - password to connect
conn = DriverManager.getConnection("jdbc:db2://localhost:6789/TESTMAN",
"administrator", "Rational");

System.out.println("..Connected");


} catch (Exception ex){
System.err.println("SQL Exception"+ ex.getMessage());
}
}

}



Disclaimer

All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

[{"Product":{"code":"SSJMXE","label":"IBM Rational Functional Tester"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Integrations: 3rd Party","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"6.1;6.1.1.1;7.0;7.0.0.1;7.0.0.2","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
16 June 2018

UID

swg21281638