By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,586 Members | 2,347 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,586 IT Pros & Developers. It's quick & easy.

An error on search table.

P: n/a

Hello,I am a fresh man to study the DB2.An error occured when I try to
Run a Java class.

Details of the Error:

Code:
--------------------

com.ibm.db2.jcc.b.SqlException:DB2 SQL error:SQLCODE:-204,SQLSTATE:42704, SQLERRMC :DB2ADMIN.TEST

--------------------
Following is the source:

Code:
--------------------

/*
* JDB2.java
*
* Created on 2006
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

/**
*
* @author Administrator
*/
import java.sql.*;
public class JDB2{
//Create the main method
public static void main(String args[]){
//Load JDBC Driver
String Driver="com.ibm.db2.jcc.DB2Driver";
//Create the URL
String Url="jdbc:db2://localhost:50000/BD";
//Use the Class.forName
try{
Class.forName(Driver).newInstance();
}catch (Exception e){
System.out.println(e);
}
//Create Connection
System.out.println("Conneting...");
try{
Connection conn=DriverManager.getConnection(Url,"db2admin","8 30401");

Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from test");
while(rs.next()) {
int ID=rs.getInt("id");
String NAME=rs.getString("name");
System.out.println("ID"+"\t\t"+"NAME");
System.out.println(ID+"\t\t"+NAME);
}
}catch(SQLException sqle){
System.err.println(sqle);
}

}
}
--------------------
--
TurboDisk
------------------------------------------------------------------------
TurboDisk's Profile: http://www.dbtalk.net/m197
View this thread: http://www.dbtalk.net/t300860

Apr 20 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
may be you are refering to the object which does not exist,
check out the table and column name you are useing

Apr 20 '06 #2

P: n/a
In article <11*********************@u72g2000cwu.googlegroups. com>,
SR********@REDIFFMAIL.COM says...
may be you are refering to the object which does not exist,
check out the table and column name you are useing


And also the table prefix. It defaults to the name of the user used in
the connect statement.
Apr 20 '06 #3

P: n/a

Thanks to everybody.But I don't know how to modify it.
--
TurboDisk
------------------------------------------------------------------------
TurboDisk's Profile: http://www.dbtalk.net/m197
View this thread: http://www.dbtalk.net/t300860

Apr 20 '06 #4

P: n/a
Change your SQL statement in the program to:
select count(*) from syscat.tables
or
values(current timestamp)

The second will always return a row while the first verifies that your
connection has read access to the database catalog tables.

Your connect statement includes the userid and password. The full table
name you are accessing is "db2admin.test". If you created the table from
a connection using your own userid, then you need to use your userid and
password in the connect statement or use:
select * from userid.test

I'd suggest reading a good primer book on db2 to learn about the basics.

Phil Sherman

TurboDisk wrote:
Hello,I am a fresh man to study the DB2.An error occured when I try to
Run a Java class.

Details of the Error:

Code:
--------------------

com.ibm.db2.jcc.b.SqlException:DB2 SQL error:SQLCODE:-204,SQLSTATE:42704, SQLERRMC :DB2ADMIN.TEST

--------------------
Following is the source:

Code:
--------------------

/*
* JDB2.java
*
* Created on 2006
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

/**
*
* @author Administrator
*/
import java.sql.*;
public class JDB2{
//Create the main method
public static void main(String args[]){
//Load JDBC Driver
String Driver="com.ibm.db2.jcc.DB2Driver";
//Create the URL
String Url="jdbc:db2://localhost:50000/BD";
//Use the Class.forName
try{
Class.forName(Driver).newInstance();
}catch (Exception e){
System.out.println(e);
}
//Create Connection
System.out.println("Conneting...");
try{
Connection conn=DriverManager.getConnection(Url,"db2admin","8 30401");

Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from test");
while(rs.next()) {
int ID=rs.getInt("id");
String NAME=rs.getString("name");
System.out.println("ID"+"\t\t"+"NAME");
System.out.println(ID+"\t\t"+NAME);
}
}catch(SQLException sqle){
System.err.println(sqle);
}

}
}
--------------------

Apr 20 '06 #5

P: n/a

Thanks very much Phil.Thanks very much everybody.
--
TurboDisk
------------------------------------------------------------------------
TurboDisk's Profile: http://www.dbtalk.net/m197
View this thread: http://www.dbtalk.net/t300860

Apr 21 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.