Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JDBC to DB2 through Windows & AIX

Status
Not open for further replies.

westhill

Programmer
May 24, 2002
1
US
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(&quot;COM.ibm.db2.jdbc.app.DB2Driver&quot;);
}
catch (ClassNotFoundException e) {
e.printStackTrace();
}
Connection HSjdbccon= DriverManager.getConnection(&quot;jdbc:db2:DALTEST&quot;,&quot;TFCMWEBU&quot;,&quot;FCMTSTU&quot;);
//Get the Result Set
Statement stmt1 = HSjdbccon.createStatement();
String strQuery = &quot;SELECT PROJNAME FROM THEMIS92.PROJ&quot;;
ResultSet rst = stmt1.executeQuery(strQuery);
if (!rst.equals(null))
{
while (rst.next()) {
String strCountTitle = rst.getString(&quot;PROJNAME&quot;);
System.out.println(&quot;Name is :&quot;+strCountTitle);
}
}

HSjdbccon.close();
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top