db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dinesh Bajaj <dinesh.ba...@ymail.com>
Subject Re: Problem storing an image in a Blob field in Java DB.
Date Fri, 12 Feb 2010 15:44:40 GMT

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.


--- On Fri, 12/2/10, Bryan Pendleton <bpendleton@amberpoint.com> wrote:

From: Bryan Pendleton <bpendleton@amberpoint.com>
Subject: Re: Problem storing an image in a Blob field in Java DB.
To: "Derby Discussion" <derby-user@db.apache.org>
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.



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