The probable cause of this exception is that you did not write the value to the database using an ObjectOutputStream. The OOS writes a header to the stream to mark it as a serialized object. The "invalid stream header" in your stack trace indicates that this header is either corrupt or does not exist.
Even I was thinking the same thing. But I dont know how to write to a ObjectOutputStream. Let me tell you my problem in detail.
I have a byte array. I created a ObjectOutputStream and I am writing this array in OOS by using write method. But how to pass it to sql querry. Because I have to store this data to database. The field type is blob. Do you know how can it be achieved??
I know that reading/writing in blob is very easy. It can be done with setBlob and getBlob. But I want to store Public Key and Private Key in database and I want to retrive these keys as it is that is as a Key because I am using it further to sign message. And there are no ways to store key in database rather than bytes or Blob. I tried for Blob but when I retrive key as Blob there are no ways to further type cast or convert it into key.
So, what I want to do is... I will retrive Key from InputStream and this InputStream I will pass to ObjectInputStream. Now from here I will extract it as Object and so I can convert it as Key.
I hope now you got what actually I want to do. I tried to store and retrive these in files rather than database, that time it works. But I want to store into database.
Please, if you have any suggestion then I will be greatful.