Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

converting InputStream....

 
Ilja Smoli
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Im not really good in streams, so here is my question...
Im serializing an object and puting it to Oracle column of type "Clob":

This works fine

Then I want to get this object from a table and Deserialize it:


Exception is : java.io.StreamCorruptedException: invalid stream header

I tried to printout InputStream and it consist of bytes
So if I understand correctly I need a stream of chars to give to ObjectInputStream so it could deserialize correctly...

If I printout this InputStream with BufferedReader, then it looks like serialized object..
So question is how to get valid Stream for ObjectInputStream?

thx in advance...
 
Joe Ess
Bartender
Posts: 9370
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Every example I've seen uses a BLOB rather than a CLOB. I'm going to toss this question over to the JDBC forum and see if anyone there has any bright ideas.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 35976
422
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ilja,
Joe is correct. Bytes are binary data and therefore BLOB (binary large objects) are used.

Databases try to encode CLOBs as character data and can get confused when unencoding them since binary data doesn't map well to characters.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!