Subject | Re: Data Type Mappings |
---|---|
Author | rrokytskyy |
Post date | 2002-06-07T15:42:24Z |
Hi,
deserialize objects. :)
Best regards,
Roman
> When reading a byte[] from the BLOB field can I do the reverse i.e.(colIndex);
> stmt = conn.prepareStatement(queryString);
> rs = stmt.executeQuery();
> if (rs.next()) {
> serializedObject = (SerializedObject) rs.getObject
> }No, this will not work. You will get ClassCastException, we do not
deserialize objects. :)
> or do I have to do the following?This is the correct approach.
> stmt = conn.prepareStatement(queryString);
> rs = stmt.executeQuery();
> if (rs.next()) {
> ObjectInputStream in = new ObjectInputStream(
> new ByteArrayInputStream(rs.getBytes(1)));
> serializedObject = (SerializedObject) in.readObject();
> }
Best regards,
Roman