Search code examples
imagebase64ibm-mobilefirstderbyclob

Retrieve base64 image stored as a CLOB from derby with Worklight adapter


I am trying to retrieve an image stored as a CLOB in a Derby DB via a Worklight SQL adapter. I would like to do something similar to what was written up here: https://www.ibm.com/developerworks/community/blogs/dhuyvett/entry/jsonstore_revisited_in_worklight_v6_part_1_the_adapter?lang=en except for the referenced article the author is using DB2. Does anyone know how I can do this in Derby? Currently when I go to retrieve the image doing a SQL Select, the string returned is

"IMAGE": "org.apache.derby.impl.jdbc.EmbedClob@2d236"

I would also consider mysql as an alternative. Thanks for any suggestions.

JT


Solution

  • org.apache.derby.impl.jdbc.EmbedClob is a java.sql.Clob, so if you have the CLOB in a var, you should be able to get the data with:

    var dataAsString = theClob.getSubString(1, theClob.length());  // Assumes all CLOBS are < 2G