Results 1 to 6 of 6
  1. #1
    newbie123 is offline Member
    Join Date
    Nov 2009
    Posts
    90
    Rep Power
    0

    Default 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.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,798
    Rep Power
    19

    Default 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.

  3. #3
    newbie123 is offline Member
    Join Date
    Nov 2009
    Posts
    90
    Rep Power
    0

    Default 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.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,798
    Rep Power
    19

    Default 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.

  5. #5
    newbie123 is offline Member
    Join Date
    Nov 2009
    Posts
    90
    Rep Power
    0

    Default 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?

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,798
    Rep Power
    19

    Default Re: loading blob data in database

    God knows what MySQL is doing with it, unless there is some minimum LOB size thing going on.

Similar Threads

  1. loading data from a text file
    By newbie123 in forum JDBC
    Replies: 1
    Last Post: 06-21-2011, 06:09 PM
  2. Save Object to Blob
    By aibao in forum NetBeans
    Replies: 1
    Last Post: 05-24-2011, 03:50 PM
  3. loading data in memory
    By robby14 in forum Advanced Java
    Replies: 10
    Last Post: 04-18-2010, 02:29 PM
  4. Java - OLE or BLOB - MS Access
    By hkansal in forum Advanced Java
    Replies: 4
    Last Post: 02-04-2009, 06:47 AM
  5. Saving Blob through Hibernate
    By Ed in forum JDBC
    Replies: 2
    Last Post: 01-05-2009, 05:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •