posted 16 years ago
Hi,
I've used bobs with the following piece of code. You could adapt it to what you require:
public void setBlob(PreparedStatement pstmt, int index, Object obj) throws DAOException, SQLException {
ByteArrayOutputStream b_out = new ByteArrayOutputStream();
try {
ObjectOutputStream o_out = new ObjectOutputStream(b_out);
o_out.writeObject(obj);
o_out.close();
} catch (IOException e) {
log.error(e);
throw new DAOException(e);
}
byte[] b = b_out.toByteArray();
ByteArrayInputStream b_in = new ByteArrayInputStream(b);
pstmt.setBinaryStream(index, b_in, b.length);
}
this method could be used by your insert or update method like this:
setBlob(pstmt1, 2, myObject);
Cheers
Parham