如何使用适配器来检索SQL Server“image”数据类型值 [英] How to use adapters to retrieve SQL Server "image" datatype value

查看:214
本文介绍了如何使用适配器来检索SQL Server“image”数据类型值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检索存储在SQL Server的 image 数据类型中的数据。但是,当我调用适配器时,我得到的是

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

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

根据这个博客我们需要从返回值中获取字节,它可能是java.sql.Blob一个简单的toString ()对象。 https://www.ibm .com / developerworks / community / blogs / dhuyvett / entry / jsonstore_revisited_in_worklight_v6_part_1_the_adapter?lang = en

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类\[B \没有公共实例字段或方法名为\getBytes \

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

所以我只是想知道SQL Server的适配器是否支持 image 数据类型?如果是,获取数据的正确方法是什么?

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?

我使用的是MFP 7.0,我已经检查了数据库。它的数据为字节数组。

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

推荐答案

我不确定getBytes。这与MobileFirst适配器无关。

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

在数据库中处理图像的建议方法是将图像编码为base64并将结果字符串保存在数据库中。然后,您可以将编码的字符串发送到客户端,以便将其解码为图像格式。 Stack Overflow中有关于此主题的几个问题。

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.

这篇关于如何使用适配器来检索SQL Server“image”数据类型值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆