将字符串传递给 VARCHAR 字段时不支持的 SQL 类型 1111

发布于 2024-08-15 16:23:48 字数 925 浏览 3 评论 0原文

我已经为此绞尽脑汁有一段时间了。

我使用 iBatis 和 JAVA 代码来运行驻留在 Sybase DB 中的存储过程。

存储过程需要一些参数。其中很少被声明为 VARCHAR (6)

因此在我的 iBatis 映射中我对这些参数执行了以下操作。

<parameter property="searchUserId" jdbcType="String" javaType="java.lang.String" mode="IN"/>

但是,当我这样做时,我收到以下错误。

--- Check the statement (update procedure failed).  
--- Cause: java.sql.SQLException: JZ006: Caught IOException: java.io.IOException: JZ0SL: Unsupported SQL type 1111.
Caused by: java.sql.SQLException: JZ006: Caught IOException: java.io.IOException: JZ0SL: Unsupported SQL type 1111.

因此,我将映射更改为以下内容:

<parameter property="searchUserId" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"/>

这消除了上面的错误,但是,现在参数 searchUserId 正在获取传递到 SP 的 null 值。我确信从我的 java 代码中我没有传递 null

有人遇到过这个问题吗?我应该将映射更改为什么?

I have been smashing my head against this for a while now.

I am using iBatis with my JAVA code to run Stored Proc residing in Sybase DB.

Stored procedure is expecting some parameters. few of them are declared as VARCHAR (6)

So in my iBatis mapping i did the following for those parameters.

<parameter property="searchUserId" jdbcType="String" javaType="java.lang.String" mode="IN"/>

However, when I do this I get the following error.

--- Check the statement (update procedure failed).  
--- Cause: java.sql.SQLException: JZ006: Caught IOException: java.io.IOException: JZ0SL: Unsupported SQL type 1111.
Caused by: java.sql.SQLException: JZ006: Caught IOException: java.io.IOException: JZ0SL: Unsupported SQL type 1111.

So I changed my mapping to following:

<parameter property="searchUserId" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"/>

which got rid of the error above, however, now the parameter searchUserId is getting value of null passed into the SP. I know for sure that from my java code I am NOT passing null.

Has someone faced this issue? what should I change my mapping to??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

白云不回头 2024-08-22 16:23:48

我出于不同的原因遇到了这个问题:该表中有一个几何(PostGIS 扩展)列,我猜驱动程序无法解析该列。删除该列使其起作用。

I ran into this problem for a different reason: The table had a geometry (PostGIS extension) column in it that I guess the driver couldn't parse. Dropping that column made it work.

五里雾 2024-08-22 16:23:48

在更改为使用 VARCHAR 作为 jdbcType 后,您的参数元素看起来没问题。您能否包含映射文件中的其余参数元素和过程元素,以及创建参数映射和调用查询的代码?

这可能是一些简单的事情,比如构建传递到查询中的映射时的拼写错误(至少这是我会犯的错误——我知道在使用 Ibatis 时我对大写“userId”不一致)。

Your parameter element looks ok, after the change to use VARCHAR as jdbcType. Could you include the rest of the parameter element and the procedure element from the mapping file, and the code that creates the parameter map and calls the query?

It could be something simple like a typo when constructing the map passed into the query (at least that's the kind of mistake I would make -- I know I've been inconsistent about capitalizing "userId" while using Ibatis).

青萝楚歌 2024-08-22 16:23:48

我也遇到过类似的情况。经过大量搜索后,最后我发现问题的答案是我在构建地图时缺少一个特定的“键”。我错过了一个声明:

map.put("job_name", job.getJobName());

&我在 CronMapper.xml 中使用 JOB_NAME=#{job_name}

还有一些我在其他地方使用 JOB_NAME=#{jobName}

I too faced a similar situation. After searching a lot, finally I found that answer to my problem was that I was missing a particular 'key' while constructing map. I was missing a statement:

map.put("job_name", job.getJobName());

& I was using JOB_NAME=#{job_name} in CronMapper.xml

Also some where else I was using JOB_NAME=#{jobName}

爱冒险 2024-08-22 16:23:48

我知道这个问题很古老,但要考虑的另一件事是 iBatis (MyBatis) 占位符中的值是否为空。就我而言,抛出错误“JZ0SL:不支持的 SQL 类型 1111”,因为传递到 String 参数的值为 null :

其中 #{daemonID​​} 为空。 hth-adym

I know this question is ancient, but 1 other thing to consider is does the value in the placeholder for iBatis (MyBatis) is null. In my case, the error "JZ0SL: Unsupported SQL type 1111" was being thrown because the value being passed into the String parameter was null :

<select id = "getInProcessDocsCount" parameterType="String" resultType ="int"> select count(*) from my_database..pub_wip_t where wip_stts_cde='IP' and rfrn_row = #{daemonID} </select>

where #{daemonID} was null. hth - adym

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文