Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

DB2 SQL error: SQLCODE: -204, SQLSTATE: 42704

843859Jan 15 2008 — edited Jan 15 2008
I don't get it. When you create a table in DB2, do you have to do anything extra to it to make it so you can do a select on it? I run my Java program with a specified name of a table which has been in the database for a long time. But then I change one single variable, the table name, and it gives me the 42704 error meaning it can't find the table. The problem is I open up Rapid SQL and can see the table that I created but it still gives me the 42704 error when I try to use it in my code. Here's what I'm talking about:
------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">

<sqlMap namespace="daemon">

<resultMap id="result" class="Daemon">
<result property="username" columnIndex="2" jdbcType="VARCHAR" javaType="java.lang.String"/>
</resultMap>

<parameterMap id="param" class="Daemon">
<parameter property="username"/>
</parameterMap>

<select id="getUsername" resultClass = "String" resultMap = "result">
select * from <tableName>
</select>
</sqlMap>
------------------------------------------------------------------
So when tableName is the table that's always been in the database, it works fine. But when I change it to the table name I created, it doesn't work. But yet the column and data types are all the same. Any ideas? Here's the method I'm using to call it.
-------------------------------------------------------------------------
public Daemon getUsername () throws SQLException
{
return (Daemon) (sqlMapper.queryForObject("getUsername"));
}
--------------------------------------------------------------------------------
Here's the error:


There is an exception: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in ..\\Daemon.xml.
--- The error occurred while applying a parameter map.
--- Check the getUsername-InlineParameterMap.
--- Check the statement (query failed).
--- Cause: com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -204, SQLSTATE: 42704, SQLERRMC: APPSFA.DUMMYTEST

Here is the stack trace:

com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in ..\\Daemon.xml.
--- The error occurred while applying a parameter map.
--- Check the getUsername-InlineParameterMap.
--- Check the statement (query failed).
--- Cause: com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -204, SQLSTATE: 42704, SQLERRMC: APPSFA.DUMMYTEST
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:185)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:566)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:541)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:110)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:87)
at Caller.getUsername(Caller.java:63)
at MainClass.main(MainClass.java:32)
Caused by: com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -204, SQLSTATE: 42704, SQLERRMC: APPSFA.DUMMYTEST
at com.ibm.db2.jcc.c.kh.c(kh.java:1660)
at com.ibm.db2.jcc.c.kh.d(kh.java:1648)
at com.ibm.db2.jcc.c.kh.a(kh.java:1205)
at com.ibm.db2.jcc.b.db.g(db.java:139)
at com.ibm.db2.jcc.b.db.a(db.java:39)
at com.ibm.db2.jcc.b.t.a(t.java:34)
at com.ibm.db2.jcc.b.sb.f(sb.java:142)
at com.ibm.db2.jcc.c.kh.m(kh.java:1176)
at com.ibm.db2.jcc.c.lh.bb(lh.java:1941)
at com.ibm.db2.jcc.c.lh.d(lh.java:2383)
at com.ibm.db2.jcc.c.lh.U(lh.java:1401)
at com.ibm.db2.jcc.c.lh.execute(lh.java:1385)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:186)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
... 8 more


Did I leave anything important out?

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Feb 12 2008
Added on Jan 15 2008
9 comments
17,671 views