Results 1 to 15 of 15
  1. #1
    Join Date
    Dec 2011
    Posts
    7

    Unanswered: 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.

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Please see 2) in http://www.dbforums.com/db2/854783-m...e-posting.html

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

    and may be more information neccesary, depending on your response ...

  3. #3
    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.

  4. #4
    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

  5. #5
    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

  6. #6
    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 ?

  7. #7
    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)

  8. #8
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    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
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

  9. #9
    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.

  10. #10
    Join Date
    Dec 2011
    Posts
    7
    Can any one please provide some help on this?

  11. #11
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    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
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

  12. #12
    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.

  13. #13
    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

  14. #14
    Join Date
    May 2016
    Posts
    1
    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???



    waleeed

  15. #15
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    you mention temporary table. Do you mean that you are attempting to use a global temporary table? If so, in your program are you performing the proper declarations of the table to instantiate it? If this is your issue, there are plenty of sample programs out there to use as an example.
    Dave

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •