ibatis 报语法错误

yxhshuaiman 2012-04-28 02:50:23


PROCEDURE [dbo].[d_dir_lists_Delete]
@node_id int
as
DELETE [d_dir_lists] WHERE node_id =@node_id

--exec d_dir_lists_Delete 111持行没有问题 数据库为sqlserver2005




//java代码
Map<String,Integer> map =new HashMap<String, Integer>();
map.put("node_id", new Integer(node));

this.getSqlMapClientTemplate().queryForObject("proTree.delRootNode",map);



//sqlMap
<parameterMap id="inParameters" class="java.util.Map">
<parameter property="node_id" jdbcType="INTEGER" javaType="java.lang.Integer" mode="IN" />
</parameterMap>
<!-- 调用存储过程,根据根节点id删除,以及它一下的所有节点 -->
<procedure id="delRootNode" parameterMap="inParameters">
   <![CDATA[{call d_dir_lists_Delete (?) }]]>
   </procedure>


这个会报错 妹的,到底那里出错了?

org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in config/ProTree.xml.
--- The error occurred while applying a parameter map.
--- Check the proTree.inParameters.
--- Check the statement (update procedure failed).
--- Cause: com.microsoft.sqlserver.jdbc.SQLServerException: ' ' 附近有语法错误。
...全文
268 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
yxhshuaiman 2012-05-02
  • 打赏
  • 举报
回复
原来错误出在这里了
        <procedure id="delRootNode" parameterMap="inParameters">
   <![CDATA[{call d_dir_lists_Delete (?) }]]>
   </procedure>

这中间有其它的字符 只是看不到而以,所以才报语法错了
yxhshuaiman 2012-04-28
  • 打赏
  • 举报
回复
[Quote=引用 16 楼 的回复:]
引用 15 楼 yxhshuaiman 的回复:
引用 13 楼 的回复:
--- The error occurred while applying a parameter map.

这句话啊,你的传入参数配置的是个Map类型,而实际你传递的是Map类型吗??


你看我写的java代码 当然是Map类型

看你的Map类型传递进去,你的存储过程能接收吗?
[/Quote]

我现在不传值了 也调用不成功了 存储过程就是一个查询 啥也不做的 也不传参数 还是报一样的错
superjava_2006 2012-04-28
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 yxhshuaiman 的回复:]
引用 13 楼 的回复:
--- The error occurred while applying a parameter map.

这句话啊,你的传入参数配置的是个Map类型,而实际你传递的是Map类型吗??


你看我写的java代码 当然是Map类型
[/Quote]
看你的Map类型传递进去,你的存储过程能接收吗?
yxhshuaiman 2012-04-28
  • 打赏
  • 举报
回复


[Quote=引用 13 楼 的回复:]
--- The error occurred while applying a parameter map.

这句话啊,你的传入参数配置的是个Map类型,而实际你传递的是Map类型吗??
[/Quote]

你看我写的java代码 当然是Map类型
superjava_2006 2012-04-28
  • 打赏
  • 举报
回复
肯定是传递参数的问题,你的存储过程中明明接收了一个int类型的参数,你要传递个IN (id1,id2)也不对啊
superjava_2006 2012-04-28
  • 打赏
  • 举报
回复
--- The error occurred while applying a parameter map.

这句话啊,你的传入参数配置的是个Map类型,而实际你传递的是Map类型吗??
liuyuhua0066 2012-04-28
  • 打赏
  • 举报
回复
九楼是
call [dbo].d_dir_lists_Delete (?)
yxhshuaiman 2012-04-28
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 的回复:]
{call dbo.d_dir_lists_Delete (?) }   
试下
[/Quote]

我上面试过了呀! 看9楼信息
liuyuhua0066 2012-04-28
  • 打赏
  • 举报
回复
{call dbo.d_dir_lists_Delete (?) }   
试下
yxhshuaiman 2012-04-28
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 的回复:]
call d_dir_lists_Delete (?)
直接放到DB里面可以执行么?
[/Quote]
[2012-04-28 16:32:19,062] [DEBUG] java.sql.Connection {conn-100027} Connection
[2012-04-28 16:32:19,062] [DEBUG] java.sql.Connection {conn-100027} Preparing Call:    {call [dbo].d_dir_lists_Delete (?) }   
[2012-04-28 16:32:19,078] [DEBUG] java.sql.PreparedStatement {pstm-100028} Executing Statement:    {call [dbo].d_dir_lists_Delete (?) }   
[2012-04-28 16:32:19,078] [DEBUG] java.sql.PreparedStatement {pstm-100028} Parameters: [1000000073]
[2012-04-28 16:32:19,078] [DEBUG] java.sql.PreparedStatement {pstm-100028} Types: [java.lang.Integer]
[2012-04-28 16:32:19,125] [INFO ] org.springframework.beans.factory.xml.XmlBeanDefinitionReader Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
[2012-04-28 16:32:19,203] [INFO ] org.springframework.jdbc.support.SQLErrorCodesFactory SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in config/ProTree.xml.
--- The error occurred while applying a parameter map.
--- Check the proTree.inParameters.
--- Check the statement (update procedure failed).
--- Cause: com.microsoft.sqlserver.jdbc.SQLServerException: ' ' 附近有语法错误。
yxhshuaiman 2012-04-28
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 的回复:]
call d_dir_lists_Delete (?)
直接放到DB里面可以执行么?
[/Quote]

不能持行 sqlserver里同exec d_dir_lists_Delete 1111 这样持行
liuyuhua0066 2012-04-28
  • 打赏
  • 举报
回复
call d_dir_lists_Delete (?)
直接放到DB里面可以执行么?
yxhshuaiman 2012-04-28
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 的回复:]
{call d_dir_lists_Delete (?)}

存储过程是不是少了package名
[/Quote]

什么是少了包名?
liuyuhua0066 2012-04-28
  • 打赏
  • 举报
回复
{call d_dir_lists_Delete (?)}

存储过程是不是少了package名
yxhshuaiman 2012-04-28
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]
给你个例子参考

Java code

/**
*调用存储过程
*xml方法
*
* 配置文件
* <select id="call" statementType="CALLABLE">
* {call pp(#{x},#{y},#{z,mode=OUT,jdbcType=INTEGER})} ……
[/Quote]


你这个是网上的 我都看好多遍了 不然不会来发贴
zhaixin1234 2012-04-28
  • 打赏
  • 举报
回复
给你个例子参考
	/**
*调用存储过程
*xml方法
*
* 配置文件
* <select id="call" statementType="CALLABLE">
* {call pp(#{x},#{y},#{z,mode=OUT,jdbcType=INTEGER})}
* </select>
*
* 存储过程
* DELIMITER $$;
* DROP PROCEDURE IF EXISTS `mydemo`.`pp`$$
* CREATE PROCEDURE `mydemo`.`pp` ( in x int,in y int,out z int )
* BEGIN
* select x + y into z;
* END$$
* DELIMITER ;$$
**/
public void call() throws IOException{
System.out.println("调用存储过程------------------------------------------");
String resource = "test/Configuration.xml";
Reader reader = Resources.getResourceAsReader(resource);
SqlSessionFactory sqlMapper = new SqlSessionFactoryBuilder().build(reader);
SqlSession session = sqlMapper.openSession();
try {
Map map = new HashMap();
map.put("x", 6);
map.put("y", 2);
map.put("z", 0);
session.selectOne("call", map);
System.out.println("存储过程返回值:"+map.get("z"));
} finally {
session.close();
}
}
yxhshuaiman 2012-04-28
  • 打赏
  • 举报
回复
居然人来呀?csdn人那里去了?
yxhshuaiman 2012-04-28
  • 打赏
  • 举报
回复
快来人啊 在线等 立马给分

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧