Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.7.8
-
Component/s: SQL processing
-
Labels:None
-
Environment:IBM DB2 9.1 with old DB2 JDBC driver db2jcc.jar
-
Number of attachments :
Description
The DB2 JDBC driver throws an exception when setting null as parameter for a prepared statement.
Stack trace (line numbers are wrong):
Caused by: com.ibm.db2.jcc.c.SqlException: Invalid data conversion: Parameter object type is invalid for requested conversion.
at com.ibm.db2.jcc.c.uf.setObject(uf.java:1215)
at groovy.sql.Sql.setObject(Sql.java:2124)
at groovy.sql.Sql.setParameters(Sql.java:2090)
at groovy.sql.Sql.getPreparedStatement(Sql.java:2318)
at groovy.sql.Sql.getPreparedStatement(Sql.java:2324)
at groovy.sql.Sql.execute(Sql.java:1113)
Please use PreparedStatement.setNull() instead of setObject() in the last line of Method groovy.sql.Sql.setObject() when value is null.
Also see JavaDoc comment for setObject() about null values.
http://download.oracle.com/javase/6/docs/api/java/sql/PreparedStatement.html#setNull(int, int)
http://download.oracle.com/javase/6/docs/api/java/sql/PreparedStatement.html#setObject(int,%20java.lang.Object)
Thank you!
Activity
blackdrag blackdrag
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Summary | Error with null parameter in prepared statements with old DB2 dricer | Error with null parameter in prepared statements with old DB2 driver |
Guillaume Laforge
made changes -
| Description |
The DB2 JDBC driver throws an exception when setting null as parameter for a prepared statement.
Stack trace (line numbers are wrong): Caused by: com.ibm.db2.jcc.c.SqlException: Invalid data conversion: Parameter object type is invalid for requested conversion. at com.ibm.db2.jcc.c.uf.setObject(uf.java:1215) at groovy.sql.Sql.setObject(Sql.java:2124) at groovy.sql.Sql.setParameters(Sql.java:2090) at groovy.sql.Sql.getPreparedStatement(Sql.java:2318) at groovy.sql.Sql.getPreparedStatement(Sql.java:2324) at groovy.sql.Sql.execute(Sql.java:1113) Please use PreparedStatement.setNull() instead of setObject() in the last line of Method groovy.sql.Sql.setObject() when value is null. Also see JavaDoc comment for setObject() about null values. http://download.oracle.com/javase/6/docs/api/java/sql/PreparedStatement.html#setNull(int, int) http://download.oracle.com/javase/6/docs/api/java/sql/PreparedStatement.html#setObject(int,%20java.lang.Object) Thank you! |
The DB2 JDBC driver throws an exception when setting null as parameter for a prepared statement.
Stack trace (line numbers are wrong): {code} Caused by: com.ibm.db2.jcc.c.SqlException: Invalid data conversion: Parameter object type is invalid for requested conversion. at com.ibm.db2.jcc.c.uf.setObject(uf.java:1215) at groovy.sql.Sql.setObject(Sql.java:2124) at groovy.sql.Sql.setParameters(Sql.java:2090) at groovy.sql.Sql.getPreparedStatement(Sql.java:2318) at groovy.sql.Sql.getPreparedStatement(Sql.java:2324) at groovy.sql.Sql.execute(Sql.java:1113) {code} Please use PreparedStatement.setNull() instead of setObject() in the last line of Method groovy.sql.Sql.setObject() when value is null. Also see JavaDoc comment for setObject() about null values. http://download.oracle.com/javase/6/docs/api/java/sql/PreparedStatement.html#setNull(int, int) http://download.oracle.com/javase/6/docs/api/java/sql/PreparedStatement.html#setObject(int,%20java.lang.Object) Thank you! |
Paul King
made changes -
| Assignee | Paul King [ paulk ] |
Paul King
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Fix Version/s | 1.8-rc-2 [ 17176 ] | |
| Fix Version/s | 1.7.9 [ 17164 ] | |
| Resolution | Fixed [ 1 ] |
Paul King
made changes -
| Status | Resolved [ 5 ] | Closed [ 6 ] |