You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by cld71 <cl...@hotmail.com> on 2008/08/28 17:52:43 UTC

Derby Blob

I am uploading a file using apache commons fileupload.
I am trying to store the file in a derby blob field.
The file is zipped with a pdf file as a zip entry.
After uploading the file, then I test the file by downloading it and the
downloaded file gives me errors.
To test what the problem is, I saved the uploaded file in a temp location
using the same methods as loading the blob, and the temp file works find.
Here is a code example:

...
byte[] data = item.
...
SerialBlob sb = new SerialBlob(data);
...
PreparedStatement ps = connection.prepareStatment("insert into
my_file(file_name, the_file) values(?,?)");
ps.setString(1,file_name);
ps.setBlob(2,sb);
ps.execute();

-- 
View this message in context: http://www.nabble.com/Derby-Blob-tp19203507p19203507.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Re: Derby Blob

Posted by Kristian Waagan <Kr...@Sun.COM>.
cld71 wrote:
> I am uploading a file using apache commons fileupload.
> I am trying to store the file in a derby blob field.
> The file is zipped with a pdf file as a zip entry.
> After uploading the file, then I test the file by downloading it and the
> downloaded file gives me errors.
> To test what the problem is, I saved the uploaded file in a temp location
> using the same methods as loading the blob, and the temp file works find.
>   

Hi,

Any chance you can write a minimal repro?
That would make investigating and debugging this a lot easier.

Is there a specific reason why you are using SerialBlob? Can you just 
use setBytes (or setBinaryStream) with the raw byte array instead and 
see if you get the same corruption error?
It would also be nice if you could state which Derby version, Java 
version and platform you are using.


thanks,
-- 
Kristian

> Here is a code example:
>
> ...
> byte[] data = item.
> ...
> SerialBlob sb = new SerialBlob(data);
> ...
> PreparedStatement ps = connection.prepareStatment("insert into
> my_file(file_name, the_file) values(?,?)");
> ps.setString(1,file_name);
> ps.setBlob(2,sb);
> ps.execute();
>
>