通过StoredProcedure(Spring,Java)传递数组或列表参数

时间:2019-02-11 12:50:45

标签: java spring jdbc

我想通过StoredProcedure传递数组或列表参数,但是我不知道该怎么做。

DB side:
CREATE TYPE ownType AS TABLE(
   ids [nvarchar](50)
)

ALTER PROCEDURE db(
   @Ids AS ownType readonly
)

Java side:
declareParameter(new SqlParameter(@Ids, Types.Array, "ownType"))

Map<String, Object> params = ImmutableMap.<String, Object>builder()
                .put(@Ids, "List or Array java object")
                .build();

StoredProcedure.execute(params)

执行它时,出现以下错误消息:

SQL state [null]; error code [0]; The conversion from UNKNOWN to ARRAY is unsupported.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The conversion from UNKNOWN to ARRAY is unsupported.",

有人有关于如何使用它的经验吗,这是什么问题?

谢谢您的答复!

0 个答案:

没有答案