Friday, April 3, 2015

How to read BLOB column in a database table and save it to a file by using Talend ?

In my development, I saved a file into BLOB column. I would like to check if the data in BLOB column is correct. I use Talend Open Studio  to create a simple job to read BLOB data out of database.

This is the simple job I created in Talend.




In this job, I used a custom component, tLOBDownload. You can download it by click on the name.
If you don't know how to install a custom component, you can reference document in Talend site.
How to install a custom component?


The detail for each component setup is as below.

This is the db2Input setup.

 This is tLOBDownload setup.  Please note the type of file is Object. (Circled in red).
The BLOB will be saved into a file.

6 comments:

  1. Hi,
    i've got a problem with the extract from mysql blob.
    It tells me : "Given object is not a Blob. It is of type:[B"
    Do you have any idea of my mistake ?
    The schema seems to be good (ie Object and Blob).
    Thank you

    ReplyDelete
  2. Am getting below error when I use tLobDownload and have followed the steps as same as above

    Detail Message: Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
    There may be some other errors caused by JVM compatibility. Make sure your JVM setup is similar to the studio.

    at org.talend.designer.runprocess.JobErrorsChecker.checkLastGenerationHasCompilationError(JobErrorsChecker.java:326)

    ReplyDelete
    Replies
    1. You have to use / instead of \ in Java. This is even true when running under Windows.

      Delete
  3. Hi,

    I'm getting the error "Given object is not a Blob. It is of type:[B", too. It is a MySQL database with a column of type "BLOB".

    The "[B" stands for byte array (see https://stackoverflow.com/questions/4606864/what-kind-of-java-type-is-b).

    ReplyDelete
    Replies
    1. For anyone who finds this, years later - this is a type conversion problem that often happens with MySQL as a data source. Details and an answer here at the end of this thread:
      https://community.talend.com/s/question/0D53p00007vCoK6CAK/to-extract-the-blob-images-from-mysql-database-and-store-it-in-local-file-system

      Delete
  4. Can anyone assist as to how to configure the path of where the blob is saved and how to config that directory

    ReplyDelete