Serializing a BLOB

I

Ike

Can anyone point me to where I can find an example of serialising a BLOB
instance for JDBC ? THanks, Ike
 
R

Roedy Green

Can anyone point me to where I can find an example of serialising a BLOB
instance for JDBC ? THanks, Ike

See http://mindprod.com/fileio.html

Tell it you have an object you would like to write to a byte array.

Now go talk to your SQL manual to see how you go about setting up a
blob object in one of your tables that will eat a byte array. Blobs
tend to be handled in a vendor specific way. I don't even know if
there is an SQL standard for them.
 
?

=?ISO-8859-1?Q?J=F6rg_Marti?=

Hello
Try this way, you dont't need to serialise the Object manualiy:

//Write into DB
PreparedStatement prepStatement = sConnection.prepareStatement("INSERT
INTO COLLECTORS (SPFINDEX, DATAOBJECT) VALUES (23424, ?)");
prepStatement.setObject(1, MyClassToStore1);
int i = prepStatement.executeUpdate();

// Read from DB
String sqlStatement = "SELECT * FROM COLLECTORS";
ResultSet rs = sStatement.executeQuery(sqlStatement);
rs.last();
MyClassToStore2 = (MyClassToStore)rs.getObject("DATAOBJECT");

Good luck
Jörg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top