Idiots guide for Blob -> Object...
Posted by: mezz2k
Date: May 24, 2005 04:26PM

First off I'm running MySQL 4.1.12 (win32) with MySQL Connector Java 3.1.8a if that helps.

All I'm trying to do is read and write objects to a MySQL table. If I can get this simple example going then I can expand it into what I actually need to do.

I have a string wrapper class which literally is a blank class storing a String and has a method to retrieve it (pretty pointless I know but good for an example). This gets shoved into a table with one Blob field. After looking around for a few hours there seems to be two ways of doing this:

One being the set and getObject methods as per the preparedStatement.executeUpdate() which I just end up with ClassCastException errors. The other being writing it as a Byte[] and then restoring it via ObjectInputStreams and the like. The problem with that is I get a StreamCorruptedException.

Anyone know of a quick example of how to do this correctly as its in danger of crossing into headache territory?

Thanks in advance.

Options: ReplyQuote

Written By
Idiots guide for Blob -> Object...
May 24, 2005 04:26PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.