Two Laptop Bag*
The moose likes JDBC and the fly likes IBM DB/2 9.7 ignoring bad SQL in prepareStatement()? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "IBM DB/2 9.7 ignoring bad SQL in prepareStatement()?" Watch "IBM DB/2 9.7 ignoring bad SQL in prepareStatement()?" New topic
Author

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

Xolani Nkosi
Ranch Hand

Joined: Apr 29, 2009
Posts: 32

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.
 
 
subject: IBM DB/2 9.7 ignoring bad SQL in prepareStatement()?
 
Similar Threads
How to store & retrieve a video file from database?
What is -Xlint in compiling java program?why this is done?
Hibernate: ORM Mapping "Could not get next sequence value" SQLCODE: -142
com.ibm.db2.jcc.a.nn: THE SQL STATEMENT IS NOT SUPPORTED.
SQLException: The connection was closed