db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kristian Waagan <Kristian.Waa...@Sun.COM>
Subject Re: Derby Blob
Date Thu, 28 Aug 2008 19:32:37 GMT
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.


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.


> 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 raw message