I'm using MySQL Connector/J 3.0.9 with MySQL 4.0.16 on a Debian Linux system. I would like to update a blob field using jdbc2.0 calls like:

byte[] cover = some_byte_data;
Blob blobCover = rs.getBlob("cover");
blobCover.setBytes(1, cover);
rs.updateBlob("cover", blobCover);

The last line always throws following exception:

java.lang.ArrayIndexOutOfBoundsException: 181980
at com.mysql.jdbc.PreparedStatement.escapeblockFast(P reparedStatement.java:2338)
at com.mysql.jdbc.PreparedStatement.setBlob(PreparedS tatement.java:358)
at com.mysql.jdbc.UpdatableResultSet.updateBlob(Updat ableResultSet.java:957)
at com.mysql.jdbc.UpdatableResultSet.updateBlob(Updat ableResultSet.java:974)

Also using prepared statements results in the same error (since updateBlob() relays on prepared statements internally, I guess).

Does anyone know a workaround for this? Or am I using the jdbc calls completely wrong? Any hints are highly appreciated.