my dog learned polymorphism
The moose likes Java in General and the fly likes How to save a Message object as a blob in Oracle database. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "How to save a Message object as a blob in Oracle database." Watch "How to save a Message object as a blob in Oracle database." New topic
Author

How to save a Message object as a blob in Oracle database.

Akhil gupta
Greenhorn

Joined: Apr 17, 2004
Posts: 2
Hi

I need to save a Message object read from a mailbox as a blob in Oracle database. While doing so I am getting the NotSerializableException, which I understand is because the Message class does not implement the Serializable interface.
Can anyone tell me how to save it? I have written the following code:
J Kneeland
Ranch Hand

Joined: Aug 15, 2004
Posts: 31
You would have to extract the data and write the data instead of he object.
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Hi AkhilGupta Gupta,

My first reaction was to say "wrap it in something that does" but, on reflection, that may be a little naive. I've not checked a spec or anything but I imagine it may be necessary for all members to be serializable, so that wouldn't help.

The other alternative is to define a SerializableMessage class and copy the state of your Message to an instance of it for serialization, then do the reverse after deserialization.

Maybe there are more elegant methods, but that's my best attempt.

Jules
Akhil gupta
Greenhorn

Joined: Apr 17, 2004
Posts: 2
Thanks Guys

Following piece of code has worked for me.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Akhil_gupta01,

Welcome to JavaRanch!

We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.

We request that display names be of the pattern FIRST_NAME + SPACE + LAST_NAME.

Thanks Pardner! Hope to see you 'round the Ranch!


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to save a Message object as a blob in Oracle database.
 
Similar Threads
write a bytearray to an oracle db
Inserting Image into Oracle.
Storing and retreiving Images in Oracle
How to store & retrieve a video file from database?
java.sql.SQLException: Non supported SQL92 token at position: 377: