getting exception-optionaldata exception

Hi,

I am trying to read data from a table which is being populated by JMS.

Following is the code I have written to extract the data from the column which is of blob datatype.

StringBuffer blob = new StringBuffer("select messageblob from jms_messages");

Connectioncon= null;

String className= null;

con = DBUtils.getConnection(DBDataSource.FQ_DS);

PreparedStatement pstmt = con.prepareStatement(blob.toString());

ResultSet rs = pstmt.executeQuery();

rs.next();

try

{

InputStream is = rs.getBlob(1).getBinaryStream();

ObjectInputStream oip = new ObjectInputStream(is);

Object object = (Object)oip.readObject();

className = object.getClass().getName();

oip.close();

is.close();

rs.close();

pstmt.close();

con.commit();

}

catch(Exception eee)

{

eee.printStackTrace();

}

I am getting OptionalDataException here

Object object = (Object)oip.readObject();

what is wrong with these code ? Can anybody suggest anything ?

[1087 byte] By [arindamdhara] at [2007-11-27 11:25:13]
# 1

This exception is thrown when unexpected data appears in the input stream from which a serialised object is being read. Accordingly to the docs there are two cases in which its thrown.

- the next stream element is primitive data. in this case eof=false and count=number of bytes of primitive data available.

- the data consumable by readObject or readExternal has been exhausted. eof=true and count =0.

Have you check which case you get ?

Tom

one9966a at 2007-7-29 16:03:08 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...