Description:
The PreparedStatement.setObject() method does not work for objects of the type Types.CLOB and Types.BLOB. When calling this method, an exception is thrown ("Unknown Types value").
How to repeat:
pstat.setObject(1, "hello", Types.CLOB);
pstat.setObject(2, new byte[]{0x1, 0x2}, Types.BLOB);
Suggested fix:
*** old/mysql-connector-java-3.0.9-stable/com/mysql/jdbc/PreparedStatement.java Wed Oct 8 00:51:35 2003
--- new/mysql-connector-java-3.0.9-stable/com/mysql/jdbc/PreparedStatement.java Thu Nov 20 15:07:12 2003
*************** public class PreparedStatement extends c
*** 841,854 ****
--- 841,865 ----
break;
+ case Types.CLOB:
+ if (parameterObj instanceof Clob) {
+ setClob(parameterIndex, (Clob)parameterObj);
+ } else {
+ setString(parameterIndex, parameterObj.toString());
+ }
+ break;
+
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
+ case Types.BLOB:
if (parameterObj instanceof String) {
setBytes(parameterIndex,
StringUtils.getBytes((String) parameterObj,
this.charConverter, this.charEncoding));
+ } else if (parameterObj instanceof Blob) {
+ setBlob(parameterIndex, (Blob)parameterObj);
} else {
setBytes(parameterIndex, (byte[]) parameterObj);
}
Description: The PreparedStatement.setObject() method does not work for objects of the type Types.CLOB and Types.BLOB. When calling this method, an exception is thrown ("Unknown Types value"). How to repeat: pstat.setObject(1, "hello", Types.CLOB); pstat.setObject(2, new byte[]{0x1, 0x2}, Types.BLOB); Suggested fix: *** old/mysql-connector-java-3.0.9-stable/com/mysql/jdbc/PreparedStatement.java Wed Oct 8 00:51:35 2003 --- new/mysql-connector-java-3.0.9-stable/com/mysql/jdbc/PreparedStatement.java Thu Nov 20 15:07:12 2003 *************** public class PreparedStatement extends c *** 841,854 **** --- 841,865 ---- break; + case Types.CLOB: + if (parameterObj instanceof Clob) { + setClob(parameterIndex, (Clob)parameterObj); + } else { + setString(parameterIndex, parameterObj.toString()); + } + break; + case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: + case Types.BLOB: if (parameterObj instanceof String) { setBytes(parameterIndex, StringUtils.getBytes((String) parameterObj, this.charConverter, this.charEncoding)); + } else if (parameterObj instanceof Blob) { + setBlob(parameterIndex, (Blob)parameterObj); } else { setBytes(parameterIndex, (byte[]) parameterObj); }