0

I retrieve data from MySQL databases using SQLAdapter this is my result when invokeAdapter

     "img": "[B@5afde945"

     "img": "[B@53dddfae"

     "img": "[B@b884386"

     "img": "[B@1f091854"

I store image's data type is "LONGBLOB" So, How to convert to image and use with tag. Thank you.

Sorry for my English. ^^.

Chanom First
  • 1,136
  • 1
  • 11
  • 25

2 Answers2

2

First off, you're not actually storing the bytes for your image in your database. If something like "[B@1f091854" is what is coming from your query, then you are actually storing the string representation of the reference to the byte array, which is useless anywhere outside of the java program that created the byte array.

You should convert your byte array to something like base64, and then store it in your database. After you do that, then you can refer to this stack overflow question to see how to display it as an image in javascript.

Community
  • 1
  • 1
jnortey
  • 1,625
  • 2
  • 10
  • 17
0

The details for MySQL might be different, but I have a write-up of how to retrieve an image from DB2 BLOB field in a Worklight adapter here: https://www.ibm.com/developerworks/community/blogs/dhuyvett/entry/jsonstore_revisited_in_worklight_v6_part_1_the_adapter

David Dhuyveter
  • 1,416
  • 9
  • 17