115 pts.
 JDBC Connection from JAVA to iSeries DB
I have a simple class that resides on my local drive. I am attempting to connect to iSeries I5V4 environment and do "select" from one of the DB files. When I run my .class file in Rational Application Development I ghet a "class not found" exception. How do I set classpath in RAD? Should my application (java class file) reside on IFS ? What should the classpath be ? New to Java... Any feedback is greatly appreciated

Software/Hardware used:
ASKED: August 12, 2009  6:39 PM
UPDATED: June 30, 2010  7:45 AM

Answer Wiki:
Hi, If your class file is in your local PC and using RAD java perspective, you can run your class. RAD's java perspective is a Java SE development tool, you don't need to set the class path in general. Do you have your java project setup in RAD ? Are you calling your java class from java project? in COM statement error is occurred. so what can i do?
Last Wiki Answer Submitted:  June 30, 2010  7:45 am  by  Murali1   45 pts.
All Answer Wiki Contributors:  Murali1   45 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

package COM.ibm.db2.jdbc.app;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.*;
import javax.sql.*;
import COM.ibm.db2.jdbc.app.DB2Driver;

public interface DB2Driver {
}
public static void main(String[string] args) {
try
{
Class.forName(“COM.ibm.db2.jcc.DB2Driver”);
Connection db2Conn = DriverManager.getConnection(“jdbc:db2:empdetails”,”db2admin”,”db2admin”);
Statement st = db2Conn.createStatement();
String myQuery = “SELECT * FROM empdetails”;
ResultSet resultSet = st.executeQuery(myQuery);
while (resultSet.next())
{
String name = resultSet.getString(“name”);
String age = resultSet.getString(“age”);
System.out.println(“Name: ” + name);
System.out.println(“Age: ” + age);
System.out.println(“——————————-”);
}
resultSet.close();
st.close();
db2Conn.close();
}
catch (ClassNotFoundException cnfe)
{
cnfe.printStackTrace();
}
catch (SQLException sqle)
{
sqle.printStackTrace();
}
}

this is my pgm. but error is occurred in [COM & main function] so what can i do? plz help me.

 40 pts.