How to use adapters to retrieve SQL Server “image” datatype value

人盡茶涼 提交于 2019-12-12 03:18:32

问题


I want to retrieve data stored in image datatype of SQL Server. But when I invoke adapter all I get is

**PHOTO": "[B@62c2805a",**

According to this blog we need to get bytes from returned value and it may be java.sql.Blob a simple toString() on the object. https://www.ibm.com/developerworks/community/blogs/dhuyvett/entry/jsonstore_revisited_in_worklight_v6_part_1_the_adapter?lang=en

When I tried getting bytes, I got following error

Java class \"[B\" has no public instance field or method named \"getBytes\

So I just wanted to know if the image data type is supported by adapters for SQL Server? If yes what is the correct approach of getting data?

I am using MFP 7.0 and I have checked DB. It has data as byte array.


回答1:


I am not sure about "getBytes". This is not related to MobileFirst adapters.

The suggested approach to working with images in your database is to encode the image into base64 and save the resulting string in the database. You can then send the encoded string to the client to be de-coded back into image form. There are several questions on this topic in Stack Overflow.



来源:https://stackoverflow.com/questions/34349179/how-to-use-adapters-to-retrieve-sql-server-image-datatype-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!