Menu

#89 LONGVARBINARY error using setObject

bug
open
nobody
jdbc (31)
5
2001-02-07
2001-02-07
Anonymous
No

using hsql version 1.42
When using setObject to set the value of a binary column a class cast error occurs.

I have made the following changes that solved the problem:

line 1048 of jdbcPreparedStatement.java:
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
// setBytes(parameterIndex,(byte[])x);
setBytes(parameterIndex,((org.hsql.ByteArray)x).byteValue());
break;

---------------------------------------------------
line 565 of Column.java -> method modified to

static Object convertObject(Object o,int type) throws SQLException {
if(o==null) {
return null;
}
switch(type) {
case BINARY:
case VARBINARY:
case LONGVARBINARY:
if( o instanceof byte[])
return new ByteArray( (byte[])o);
else
return convertString(o.toString(),type);
default:
return convertString(o.toString(),type);
}
}
-------------
ByteArray.java -> added new constructor

ByteArray(byte []a) {
data=a;
}

Discussion


Log in to post a comment.

MongoDB Logo MongoDB