java 将字符串传递给 VARCHAR 字段时不支持的 SQL 类型 1111
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1955052/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unsupported SQL Type 1111 when passing String to a VARCHAR field
提问by Omnipresent
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.
我正在使用 iBatis 和我的 JAVA 代码来运行驻留在 Sybase DB 中的存储过程。
Stored procedure is expecting some parameters. few of them are declared as VARCHAR (6)
存储过程需要一些参数。其中很少有人被声明为VARCHAR (6)
So in my iBatis mapping i did the following for those parameters.
所以在我的 iBatis 映射中,我对这些参数做了以下操作。
<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 searchUserIdis getting value of nullpassed into the SP. I know for sure that from my java code I am NOT passing null.
消除了上面的错误,但是,现在参数searchUserId正在获取null传递给 SP 的值。我确信从我的 Java 代码中我没有通过null。
Has someone faced this issue? what should I change my mapping to??
有人遇到过这个问题吗?我应该将我的映射更改为什么?
采纳答案by Nathan Hughes
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?
在更改为使用 VARCHAR 作为 jdbcType 之后,您的参数元素看起来不错。您能否包括映射文件中的其余参数元素和过程元素,以及创建参数映射和调用查询的代码?
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).
在构建传递给查询的地图时,这可能很简单,比如输入错误(至少这是我会犯的那种错误——我知道我在使用 Ibatis 时对“userId”的大写不一致)。
回答by sudo
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.
由于不同的原因,我遇到了这个问题:该表中有一个geometry(PostGIS 扩展)列,我猜驱动程序无法解析。删除该列使其工作。
回答by Pratik Kumar
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
&我在 CronMapper.xml 中使用 JOB_NAME=#{job_name}
Also some where else I was using JOB_NAME=#{jobName}
还有我在其他地方使用 JOB_NAME=#{jobName}

