We need to connect to a DB2 database on Mainframe(MVS) through JDBC.
A sample connection program worked well when run on Windows NT with JDK 1.3 . The machine also had a DB2 Client installed.
The same program was posted to an AIX (unix) system - and it throws an exception.
The exception and the program are given below :
----Exception message---
Exception in thread "main" COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] SQL1
013N The database alias name or database name "DALTEST" could not be found. SQ
LSTATE=42705
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Exception.java:42)
at java.sql.SQLException.<init>(SQLException.java:43)
at COM.ibm.db2.jdbc.DB2Exception.<init>(DB2Exception.java:93)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Compile
d Code)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(SQLExcep
tionGenerator.java:409)
at COM.ibm.db2.jdbc.app.DB2Connection.connect(Compiled Code)
at COM.ibm.db2.jdbc.app.DB2Connection.<init>(DB2Connection.java:321)
at COM.ibm.db2.jdbc.app.DB2Driver.connect(DB2Driver.java:337)
at java.sql.DriverManager.getConnection(Compiled Code)
at java.sql.DriverManager.getConnection(DriverManager.java:137)
at HighSalary.main(Compiled Code)
--- Sample Program --
import sqlj.runtime.*;
import java.sql.*;
public class HighSalary
{
public static void main (String[] args) // Main entry point
throws SQLException
{
try {
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver"
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
Connection HSjdbccon= DriverManager.getConnection("jdbc:db2ALTEST","TFCMWEBU","FCMTSTU"
//Get the Result Set
Statement stmt1 = HSjdbccon.createStatement();
String strQuery = "SELECT PROJNAME FROM THEMIS92.PROJ";
ResultSet rst = stmt1.executeQuery(strQuery);
if (!rst.equals(null))
{
while (rst.next()) {
String strCountTitle = rst.getString("PROJNAME"
System.out.println("Name is :"+strCountTitle);
}
}
HSjdbccon.close();
}
}
A sample connection program worked well when run on Windows NT with JDK 1.3 . The machine also had a DB2 Client installed.
The same program was posted to an AIX (unix) system - and it throws an exception.
The exception and the program are given below :
----Exception message---
Exception in thread "main" COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] SQL1
013N The database alias name or database name "DALTEST" could not be found. SQ
LSTATE=42705
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Exception.java:42)
at java.sql.SQLException.<init>(SQLException.java:43)
at COM.ibm.db2.jdbc.DB2Exception.<init>(DB2Exception.java:93)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Compile
d Code)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(SQLExcep
tionGenerator.java:409)
at COM.ibm.db2.jdbc.app.DB2Connection.connect(Compiled Code)
at COM.ibm.db2.jdbc.app.DB2Connection.<init>(DB2Connection.java:321)
at COM.ibm.db2.jdbc.app.DB2Driver.connect(DB2Driver.java:337)
at java.sql.DriverManager.getConnection(Compiled Code)
at java.sql.DriverManager.getConnection(DriverManager.java:137)
at HighSalary.main(Compiled Code)
--- Sample Program --
import sqlj.runtime.*;
import java.sql.*;
public class HighSalary
{
public static void main (String[] args) // Main entry point
throws SQLException
{
try {
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver"
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
Connection HSjdbccon= DriverManager.getConnection("jdbc:db2ALTEST","TFCMWEBU","FCMTSTU"
//Get the Result Set
Statement stmt1 = HSjdbccon.createStatement();
String strQuery = "SELECT PROJNAME FROM THEMIS92.PROJ";
ResultSet rst = stmt1.executeQuery(strQuery);
if (!rst.equals(null))
{
while (rst.next()) {
String strCountTitle = rst.getString("PROJNAME"
System.out.println("Name is :"+strCountTitle);
}
}
HSjdbccon.close();
}
}