}
private static void updateBlobWithUpdateBinaryStream(ResultSet rs)
throws SQLException
{
Blob b;
byte[] value, expectedValue;
String blobData = "initial blob ";
String updatedBlobData = "updated blob ";
b = rs.getBlob(2);
// check contents
value = b.getBytes(1, blobData.length() + 1);
expectedValue = (blobData + rs.getInt(1)).getBytes();
if (!Arrays.equals(value, expectedValue)) {
System.out.println("blobTest11 - Error: wrong blob value");
}
// update contents
value = (updatedBlobData + rs.getInt(1)).getBytes();
InputStream updateValue = new ByteArrayInputStream(value);
rs.updateBinaryStream(2, updateValue, value.length);
rs.updateRow();
// check update values
rs.next(); // leave the row
rs.previous(); // go back to updated row
b = rs.getBlob(2);
// check contents
value = b.getBytes(1, updatedBlobData.length() + 1);
expectedValue = (updatedBlobData + rs.getInt(1)).getBytes();
if (!Arrays.equals(value, expectedValue))
{
System.out.println("blobTest11 - Error: wrong blob value");
}