jasleen12345 0 Newbie Poster

hi
i am entirely new to eclipse, db2 and wasce. but for a certain project i need to make a project using the above tools in java. so i did the following
1. Installed db2 v 9.7 with username & password both admin
2. Installed wasce
3. Installed Eclipse

my jsp pages are working fine means my eclipse and wasce have been successfully connected.
but i am unable to access my db2 database. i added the db2 drivers into my project.
and this is a code i got from documentation book of ibm. i modified it a little.

import java.sql.*; 
public class EzJava
{
public static void main(String[] args)
{
String urlPrefix = "jdbc:db2:";
String url;
String user;
String password;
String empNo; 
Connection con;
Statement stmt;
ResultSet rs;
System.out.println ("**** Enter class EzJava");


url = urlPrefix + "SAMPLE";
user = "ADMIN";
password = "admin";
try
{
// Load the driver
Class.forName("com.ibm.db2.jcc.DB2Driver");
System.out.println("**** Loaded the JDBC driver");
// Create the connection using the IBM Data Server Driver for JDBC and SQLJ
con = DriverManager.getConnection (url, user, password);
// Commit changes manually
con.setAutoCommit(false);
System.out.println("**** Created a JDBC connection to the data source");
// Create the Statement
stmt = con.createStatement();
System.out.println("**** Created JDBC Statement object");
// Execute a query and generate a ResultSet instance
rs = stmt.executeQuery("SELECT * FROM PRODUCT"); 
System.out.println("**** Created JDBC ResultSet object");
// Print all of the employee numbers to standard output device
while (rs.next()) {
empNo = rs.getString(1);
System.out.println("Employee number = " + empNo);
}
System.out.println("**** Fetched all rows from JDBC ResultSet");
// Close the ResultSet
rs.close();
System.out.println("**** Closed JDBC ResultSet");
// Close the Statement
stmt.close();
System.out.println("**** Closed JDBC Statement");
// Connection must be on a unit-of-work boundary to allow close
con.commit();
System.out.println ( "**** Transaction committed" );
// Close the connection
con.close();
System.out.println("**** Disconnected from data source");
System.out.println("**** JDBC Exit from class EzJava - no errors");
}
catch (ClassNotFoundException e)
{
System.err.println("Could not load JDBC driver");
System.out.println("Exception: " + e);
e.printStackTrace();
}
catch(SQLException ex) 
{
System.err.println("SQLException information");
while(ex!=null) {
System.err.println ("Error msg: " + ex.getMessage());
System.err.println ("SQLSTATE: " + ex.getSQLState());
System.err.println ("Error code: " + ex.getErrorCode());
ex.printStackTrace();
ex = ex.getNextException(); // For drivers that support chained exceptions

}
}
} // End main
} // End EzJava

I am getting the following error

**** Enter class EzJava
**** Loaded the JDBC driver
**** Created a JDBC connection to the data source
**** Created JDBC Statement object
SQLException information
Error msg: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=ADMIN.PRODUCT, DRIVER=3.59.81
SQLSTATE: 42704
Error code: -204
com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=ADMIN.PRODUCT, DRIVER=3.59.81
	at com.ibm.db2.jcc.am.dd.a(dd.java:676)
	at com.ibm.db2.jcc.am.dd.a(dd.java:60)
	at com.ibm.db2.jcc.am.dd.a(dd.java:127)
	at com.ibm.db2.jcc.am.bn.c(bn.java:2546)
	at com.ibm.db2.jcc.am.bn.d(bn.java:2534)
	at com.ibm.db2.jcc.am.bn.a(bn.java:2026)
	at com.ibm.db2.jcc.t4.cb.g(cb.java:140)
	at com.ibm.db2.jcc.t4.cb.a(cb.java:40)
	at com.ibm.db2.jcc.t4.q.a(q.java:32)
	at com.ibm.db2.jcc.t4.rb.i(rb.java:135)
	at com.ibm.db2.jcc.am.bn.gb(bn.java:1997)
	at com.ibm.db2.jcc.am.bn.a(bn.java:2997)
	at com.ibm.db2.jcc.am.bn.a(bn.java:659)
	at com.ibm.db2.jcc.am.bn.executeQuery(bn.java:643)
	at EzJava.main(EzJava.java:44)
Error msg: DB2 SQL Error: SQLCODE=-727, SQLSTATE=56098, SQLERRMC=2;-204;42704;ADMIN.PRODUCT, DRIVER=3.59.81
SQLSTATE: 56098
Error code: -727
com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-727, SQLSTATE=56098, SQLERRMC=2;-204;42704;ADMIN.PRODUCT, DRIVER=3.59.81
	at com.ibm.db2.jcc.am.dd.a(dd.java:679)
	at com.ibm.db2.jcc.am.dd.a(dd.java:60)
	at com.ibm.db2.jcc.am.dd.a(dd.java:127)
	at com.ibm.db2.jcc.am.bn.c(bn.java:2546)
	at com.ibm.db2.jcc.am.bn.a(bn.java:2053)
	at com.ibm.db2.jcc.t4.cb.n(cb.java:802)
	at com.ibm.db2.jcc.t4.cb.i(cb.java:259)
	at com.ibm.db2.jcc.t4.cb.c(cb.java:54)
	at com.ibm.db2.jcc.t4.q.c(q.java:44)
	at com.ibm.db2.jcc.t4.rb.j(rb.java:147)
	at com.ibm.db2.jcc.am.bn.ib(bn.java:2048)
	at com.ibm.db2.jcc.am.bn.a(bn.java:3000)
	at com.ibm.db2.jcc.am.bn.a(bn.java:659)
	at com.ibm.db2.jcc.am.bn.executeQuery(bn.java:643)
	at EzJava.main(EzJava.java:44)

i have checked again and again that their exists a product table exists in sample db......pls help........i have googled.......read a lot of documentation.....but i am not able to understand.........anyone please help.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.