We had this error code occuring during execution of an SQL statement in a J2EE application to DB2 in WebSphere.
A google search turned up a thin number of documents that hinted the problem was due to a malformed SQL Query. Looking at the code, everything looked ok. Connections were closed in the correct spots, the statement was being executed.
More interestingly, it was reported that this exception occurred on the SECOND invocation of the code. Usually, when something works once and then fails a second time in a piece of WebSphere that is heavily used like connecting to JDBC providers, I suspect the custom code before I point a finger at the platform.
When I looked at the code, I noticed:
String sqlString = ""
For (condition) {
sqlString.append("INSERT INTO...");
}
Basically, the developer had missed re-initializing the value of the string over subsequent iterations of the loop. The second time through the loop the SQL string would look like:
INSERT INTO .... ?,);INSERT INTO .... VALUES...?);
What annoys me is that rather than DB2 telling me simply “Hey, you’ve got two SQL statements chained together and that’s invalid”, it gives me an error code that relates to nothing. It has corrupted the problem from the developers problem domain to the DB2 problem domain. The developer would instantly recognize two SQL statements being chained together. The developer will never understand that SQLCODE -104, SQLSTATE 42601 means anything.
I’d love to see a new IBM policy of presenting exceptions in the domain of the user rather than the domain of the product developer.
Related Posts