If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Getting error SQLCODE:-204 SQLSTATE:42704

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-29-11, 03:49
dubeyanurodh dubeyanurodh is offline
Registered User
 
Join Date: Dec 2011
Posts: 7
Getting error SQLCODE:-204 SQLSTATE:42704

Hi,

I am facing issue accessing db2 table. getting SQLCODE: -204 SQLSTATE: 42704.

I am able to access same table from command line but not through JDBC. Other tables in same schema are accessible but tables which are created at run time are not accessible.

not sure whether it is DB2 or JDBC issue.

DB2 version is 9.5 and OS is AIX.

Can any one please help me out.

Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 12-29-11, 04:02
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,812
Please see 2) in Must Read before posting

Quote:
tables which are created at run time
Publish complete statements to create the tables.

and may be more information neccesary, depending on your response ...
Reply With Quote
  #3 (permalink)  
Old 12-29-11, 04:49
dubeyanurodh dubeyanurodh is offline
Registered User
 
Join Date: Dec 2011
Posts: 7
Here is command I am using to create table:

create table schemaName.tblName(field1 varchar(2),field2 varchar(30));

I am able to access this through following command:

db2 "select * from schemaName.tblName"

but with JDBC it give SQLCODE=-204 SQLSTATE:42704.
Reply With Quote
  #4 (permalink)  
Old 12-29-11, 09:25
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,721
SQLCODE -204 corresponds to message SQL0204: SQL0204N

So I guess you are not showing us exactly what you do in the Java code (or you are connecting to a different database or DB2 instance). Or you have not committed the CREATE TABLE yet.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 01-02-12, 02:26
dubeyanurodh dubeyanurodh is offline
Registered User
 
Join Date: Dec 2011
Posts: 7
Hi Knut,
Thanks for your reply.
Here is my java code to connect to database and execute sql:

------------Code to establish connection --

Class.forName("com.ibm.db2.jcc.DB2Driver");

String databaseURL = "jdbc:db2://"+host+":"+port+"/"+dbName;

Properties properties = new Properties();

properties.put("user", userId);

properties.put("password", password);

dbConnection = DriverManager.getConnection(databaseURL,properties );


----- Code to execute sql statement

statement=dbConnection.createStatement();

statement.execute("select * from schemaName.tblName");

Thanks,
Anurodh
Reply With Quote
  #6 (permalink)  
Old 01-02-12, 03:54
amitrai4 amitrai4 is offline
Registered User
 
Join Date: Aug 2011
Posts: 46
In this code, where is the create table statement? Are you creating the table within the same application code or it is created by another thread ?
Reply With Quote
  #7 (permalink)  
Old 01-02-12, 05:23
dubeyanurodh dubeyanurodh is offline
Registered User
 
Join Date: Dec 2011
Posts: 7
I am manually creating table with following command.

create table schemaName.tblName(field1 varchar(2),field2 varchar(30));

and after that I am able to execute select query from command line using :

db2 "select * from schemaName.tblName"

Only issue with JDBC. I get following error :

com.ibm.db2.jcc.b.eo: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=SCHEMANAME.TBLNAME, DRIVER=3.53.95

at com.ibm.db2.jcc.b.bd.a(bd.java:676)

at com.ibm.db2.jcc.b.bd.a(bd.java:60)

at com.ibm.db2.jcc.b.bd.a(bd.java:127)

at com.ibm.db2.jcc.b.gm.c(gm.java:2484)

at com.ibm.db2.jcc.b.gm.d(gm.java:2461)

at com.ibm.db2.jcc.b.gm.a(gm.java:1962)

at com.ibm.db2.jcc.t4.db.g(db.java:138)

at com.ibm.db2.jcc.t4.db.a(db.java:38)

at com.ibm.db2.jcc.t4.t.a(t.java:32)

at com.ibm.db2.jcc.t4.sb.h(sb.java:141)

at com.ibm.db2.jcc.b.gm.bb(gm.java:1933)

at com.ibm.db2.jcc.b.gm.a(gm.java:2799)

at com.ibm.db2.jcc.b.gm.e(gm.java:961)

at com.ibm.db2.jcc.b.gm.execute(gm.java:945)

at Database.insertEntity(Database.java:222)

at Database.main(Database.java:49)
Reply With Quote
  #8 (permalink)  
Old 01-02-12, 05:29
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,778
try to create a test program that executes
select distinct creator from sysibm.systables
select creator,name from sysibm.systables where creator='SCHEMANAME'
in that case you can verify if the entry exists in catalog and if connected to correct db
the both commands can also be executed locally to check
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7-V10 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #9 (permalink)  
Old 01-02-12, 08:51
dubeyanurodh dubeyanurodh is offline
Registered User
 
Join Date: Dec 2011
Posts: 7
Thanks for your reply
I executed command locally and table 'TBLNAME' exists with creator 'SCHEMANAME'.

also I don't have problem accessing other tables in same schema. Only temp tables that are being created during the process or I am creating manually are not accessible.

It started when we migrated application to AIX, application was working fine on Linux server.
Reply With Quote
  #10 (permalink)  
Old 01-05-12, 05:25
dubeyanurodh dubeyanurodh is offline
Registered User
 
Join Date: Dec 2011
Posts: 7
Can any one please provide some help on this?
Reply With Quote
  #11 (permalink)  
Old 01-05-12, 05:30
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,778
we have given already many hints
you never publish the details we have requested
do some pd/psi to identifiy together with the hints the root of the problem
do step-by-step testing and check after each step
verify always twice that schema/name is specified correctly and in the correct case ..
check the catalogs manually..
we can not see from here what is going on.. or you can request me to come over ..
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7-V10 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #12 (permalink)  
Old 01-06-12, 04:20
dubeyanurodh dubeyanurodh is offline
Registered User
 
Join Date: Dec 2011
Posts: 7
I have published all the details requested.
Please let me know what else you need. I have following all the instruction and checking every thing manually.
Reply With Quote
  #13 (permalink)  
Old 01-06-12, 05:06
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,721
As we said: check that you have committed the transaction executing the CREATE TABLE statement. And also check that you are connected to the correct database at the correct DB2 server.

You may want to execute a query like "SELECT * FROM syscat.tables" to see which tables are available at the server you are running your SQL statement against. If a table with schema name "SCHEMANAME" and unqualified table name "TBLNAME" does not show up in the result, the table simply doesn't exist.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On