Hi Bryan, Kristian and Arin,

Many thanks for your replies.

The first post to this thread was also my first post to this forum, and I 
understand it was therefore moderated. It appears that due to a technical 
fault, it was not forwarded to the list members.

Coming back to the issue, I have now figured out the root cause of the 
problem.  The problem was arising as I was invoking the method 
ImageIO.read(fis) on the FileInputStream instance, before sending the same 
stream instance to the SetBinaryStream method.

I understand that reading the inputstream was causing the pointer to move to 
the end of the stream, and therefore no data was getting stored in the Derby 
database. I amended the code, and the problem is now fixed. What a great 
relieve as this problem was bugging me for the last 3-4 days, and I can't 
believe that I couldn't figure it out earlier.

Anyways, many thanks for all your input.

Regards,
Dinesh


--- On Fri, 12/2/10, Bryan Pendleton <[email protected]> wrote:

From: Bryan Pendleton <[email protected]>
Subject: Re: Problem storing an image in a Blob field in Java DB.
To: "Derby Discussion" <[email protected]>
Date: Friday, 12 February, 2010, 8:57 PM

Dinesh Bajaj wrote:
>     preparedStatement.setBinaryStream(5, inputStream, file.length());

>     Message = Java exception: 'Input stream did not have exact amount of
>     data as the requested length.:

Can you show more of your actual code? It sounds like 'inputStream'
is not returning the data which is in 'file'.

Paste in a larger segment of your code, showing all the activity to
'inputStream' and 'file' since they were declared as variables.

thanks,

bryan




      Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! 
http://downloads.yahoo.com/in/internetexplorer/

Reply via email to