loading blob data in database
This is a bit off topic, but maybe you can help.
I want to store a series of .jpg images as blob data in a Derby database on a server. A Java client program will them access that database, allowing the user to view them.
The algorithm for downloading the blob data seems pretty straightforward.
How do I actually (bulk) import the .jpg images in the database using Derby's ij utility? I have tried using the Derby system procedure
syscs_util.syscs_import_table
but I get the error
an invalid hexadecimal string 'image_6_16.jpg' detected in import file
I suppose I could write a little Java program to upload it as a binary stream, bit this seems like overkill.
Re: loading blob data in database
According to the docs you want one of SYSCS_UTIL.SYSCS_IMPORT_TABLE_LOBS_FROM_EXTFILE or SYSCS_UTIL.SYSCS_IMPORT_DATA_LOBS_FROM_EXTFILE. The one you're using is expecting the data in the import file.
As for how, exactly, you use them I have no idea.
Re: loading blob data in database
That's the problem. Even after looking at the examples associated with the SYSCS_UTIL.SYSCS_IMPORT_TABLE_LOBS_FROM_EXTFILE, it is not clear how to do this. My trial and error has not worked as yet.
Re: loading blob data in database
Get an entry in the table (just the one) with an image LOB.
Then do the export as separate file (can't remember the name of the util, but presumably EXPORT_TABLE_LOBS_TO_EXTFILE?) and see whether MySQL does some funky naming thing for the files in the export file (not the image files). There is something in the link I posted about the LOB file reference in the main import file...ah, here:
"
If you are importing data from a non-Derby source, the references to the LOB data must be in the main import file in the format lobsFileName.Offset.length/. This is the same method that the Derby export procedures use to export the LOB data to a separate external file.
"
So, by exporting a sample you should then get an idea of what it expects for an import.
Re: loading blob data in database
Thanks for your help Toll. I have posed this question to some database "gurus". If there is a simple way to do this, they don't know about it. A little sad.
I just wrote a little Java program (in about 5 minutes) that works just fine.
It does raise another question with regard to efficiency.
When I store the jpg as a bin in the database, it expands in size. For example, it goes from 50 KB to something approaching 500 KB.
Maybe it would be more efficient in terms of bandwidth to have the client download the jpgs from the server instead of futzing around with the database.
What do you think?
Re: loading blob data in database
God knows what MySQL is doing with it, unless there is some minimum LOB size thing going on.