aspose file tools*
The moose likes JDBC and the fly likes iSeries V5R2-Native DB2 access in QShell-ClassNotFoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "iSeries V5R2-Native DB2 access in QShell-ClassNotFoundException" Watch "iSeries V5R2-Native DB2 access in QShell-ClassNotFoundException" New topic
Author

iSeries V5R2-Native DB2 access in QShell-ClassNotFoundException

Reed Peters
Ranch Hand

Joined: Jul 23, 2002
Posts: 38
I am getting a ClassNotFoundException on the DB2 native driver and can not for the life of me figure out why. If you are familiar with running Java programs on an iSeries (AS400), not in WebSphere AS but in QShell, I sure wish you would help. Below you will find my environment variable setting for classpath (WRKENVVAR), followed by the QShell display echoing the classpath and running the java program "JavaApp1". After that the Java program is listed.
Thanks, Reed Peters
--------------------------------
Environment Variable CLASSPATH
--------------------------------
Display Environment Var (*JOB)
Name . . . . . . . . . : CLASSPATH
Value . . . . . . . . . : '.:/QIBM/ProdData/Java400/:/QIBM/ProdData/OS400/Java400/ext/jdbc2_0-stdext.jar:/QIBM/ProdData/OS400/Java400/ext/db2_classes.jar'
------------------------------
QShell Display - Showing error
------------------------------
STRQSH
$
echo $CLASSPATH

.:/QIBM/ProdData/Java400/:/QIBM/ProdData/OS400/Java400/ext/jdbc2_0-stdext.jar:/QIBM/ProdData/OS400/Java400/ext/db2_classes.jar
$
java JavaApp1
Pgm Version: C
Statement: Class.forName(com.ibm.db2.jdbc.app.DB2Driver)
Exception occured Step 1!
Message: com/ibm/db2/jdbc/app/DB2Driver
java.lang.ClassNotFoundException: com/ibm/db2/jdbc/app/DB2Driver java/lang/Throwable.<init>(Ljava/lang/String V+4 (Throwable.java:90)
java/lang/Exception.<init>(Ljava/lang/String V+1 (Exception.java:38)
java/lang/ClassNotFoundException.<init>(Ljava/lang/String V+1 (ClassNotFoundException.java:65)
java/lang/Class.forName(Ljava/lang/String Ljava/lang/Class;+5 (Class.java:121)
JavaApp1.main([Ljava/lang/String V+18 (JavaApp1.java:21)
Statement: DriverManager.registerDriver(new com.ibm.db2.jdbc.app.DB2Driver())

java.lang.NoClassDefFoundError: com/ibm/db2/jdbc/app/DB2Driver java/lang/Throwable.<init>(Ljava/lang/String V+4 (Throwable.java:90)
java/lang/Error.<init>(Ljava/lang/String V+1 (Error.java:46)
java/lang/NoClassDefFoundError.<init>(Ljava/lang/String V+1 (NoClassDefFoundError.java:43)
JavaApp1.main([Ljava/lang/String V+73 (JavaApp1.java:30)
$
---------------------------------
Java Code:
---------------------------------
public class JavaApp1 {
public static void main(String[] args) {
Connection con = null;

System.out.println("Pgm Version: C");
System.out.println("Statement: Class.forName(com.ibm.db2.jdbc.app.DB2Driver)");
try {
Class.forName("com.ibm.db2.jdbc.app.DB2Driver");
} catch (Exception e) {
System.out.println("Exception occured Step 1!");
System.out.println("Message: " + e.getMessage());
e.printStackTrace();
}
System.out.println("Statement: DriverManager.registerDriver(new com.ibm.db2.jdbc.app.DB2Driver())");
try {
DriverManager.registerDriver(new com.ibm.db2.jdbc.app.DB2Driver());
} catch (Exception e) {
System.out.println("Exception occured Step 2!");
System.out.println("Message: " + e.getMessage());
e.printStackTrace();
}
try {
con = DriverManager.getConnection("jdbc b2://localhost", "user", "password");
} catch (Exception e) {
System.out.println("Exception occured Step 3!");
System.out.println("Message: " + e.getMessage());
e.printStackTrace();
}
try {
if (con instanceof com.ibm.db2.jdbc.app.DB2Connection)
System.out.println("con is running under the native JDBC driver.");
} catch (Exception e) {
System.out.println("Exception occured Step 4!");
System.out.println("Message: " + e.getMessage());
e.printStackTrace();
}
try {
con.close();
} catch (Exception e) {
System.out.println("Exception occured Step 5!");
System.out.println("Message: " + e.getMessage());
e.printStackTrace();
}
}
}


Reed Peters<br />Reed@cm-inc.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: iSeries V5R2-Native DB2 access in QShell-ClassNotFoundException
 
Similar Threads
New to packages, works in 1.5 not 1.4
Jun Hong need help java.lang.NoClassDefFoundError:
What is "FATAL ERROR in native method: Expected a string´┐Ż?
Adding a package statement makes jar not visible during runtime?
java.sql.SQLException: No suitable driver