• Post Reply Bookmark Topic Watch Topic
  • New Topic

IBM DB/2 9.7 ignoring bad SQL in prepareStatement()?

Xolani Nkosi
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm currently converting an app that we'd developed using Oracle onto DB/2, and noticed something very strange related to the above bit of code. For some reason, the DB/2 driver ignored the incorrect (Oracle specific) SQL in my prepared statement, and went on to attempt to execute the query, which then threw this error:

com.ibm.websphere.ce.cm.ObjectClosedException: DSRA9110E: Statement is closed.
at com.ibm.ws.rsadapter.jdbc.WSJdbcWrapper.createClosedException(WSJdbcWrapper.java:110)
at com.ibm.ws.rsadapter.jdbc.WSJdbcStatement.runtimeXIfNotClosed(WSJdbcStatement.java:1747)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeQuery(WSJdbcPreparedStatement.java:727)
at uk.co.liss.base.common.DatabaseSupport.getNextIdentifier(DatabaseSupport.java:156)

So my question is, why does the DB/2 driver not throw SQLException when you attempt to prepare completely wrong SQL? In the above example, the sys.dual table doesn't exist - if I try this via a SQL worksheet I get:

------------------------------ Commands Entered ------------------------------
select seq_uw_dictionary.nextval from sys.dual;
select seq_uw_dictionary.nextval from sys.dual
SQL0204N "SYS.DUAL" is an undefined name. SQLSTATE=42704

SQL0204N "SYS.DUAL " is an undefined name.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!