ibatis调用mysql存储过程出错,求解?

咖啡加糖_ 2014-02-26 01:49:38
错误信息为:
org.springframework.jdbc.UncategorizedSQLException:SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [S1009]; error code [0]; --- The error occurred while applying a parameter map. --- Check the callEmpTreeList-InlineParameterMap. --- Check the statement (update procedure failed). --- Cause: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:


java 代码:
Map newMap = new HashMap();
newMap.put("organId", "0");
getSqlMapClientTemplate().insert(
"callEmpTreeList", newMap);
xml配置为:
<procedure id="callEmpTreeList" parameterClass="java.util.HashMap">
{call Pro_GetEmpTreeList('4028804a274a8bb10128fd56877e4d44')}
</procedure>

存储过程为:
CREATE PROCEDURE `Pro_GetEmpTreeList`(in pid varchar(36))
begin
declare lev int;
set lev=1;
drop table if exists tmp1;
CREATE TABLE tmp1(id VARCHAR(40),employee_organname varchar(50),parentid varchar(40) ,levv INT);
INSERT tmp1 SELECT id,employee_organname,parent_id,1 FROM `hr_employee` WHERE parent_id=pid;
while row_count()>0
do set lev=lev+1;
INSERT tmp1 SELECT t.id,t.employee_organname,t.parent_id,lev from hr_employee t join tmp1 a on t.parent_id=a.id AND levv=lev-1;
end while ;
INSERT tmp1 SELECT id,employee_organname,parent_id,0 FROM hr_employee WHERE id=pid;
end
我这里为了测试就没传参数直接写死,直接在mysql中执行call Pro_GetEmpTreeList('4028804a274a8bb10128fd56877e4d44')是没有问题的,


求解........
...全文
224 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
Defonds 2014-02-26
  • 打赏
  • 举报
回复
你用 jdbc 调用能行不
咖啡加糖_ 2014-02-26
  • 打赏
  • 举报
回复
引用 13 楼 fangmingshijie 的回复:
{call Pro_GetEmpTreeList(#value#)}这里参数应该传问号,然后在代码里把值附上。
用的框架做了小许封装 ,如果传的是String ,就是用这个的
  • 打赏
  • 举报
回复
{call Pro_GetEmpTreeList(#value#)}这里参数应该传问号,然后在代码里把值附上。
咖啡加糖_ 2014-02-26
  • 打赏
  • 举报
回复
引用 8 楼 defonds 的回复:
[quote=引用 7 楼 jimmy609 的回复:] [quote=引用 6 楼 defonds 的回复:] [quote=引用 5 楼 jimmy609 的回复:] [quote=引用 3 楼 defonds 的回复:] 你这样,以 string 传给 ibatis 试试:
<procedure id="callEmpTreeList" parameterClass="java.lang.String">
{call Pro_GetEmpTreeList(#str#)}
</procedure>
试过了 不行的 [/quote]这样写,报啥错[/quote] 一样的错误 org.springframework.jdbc.UncategorizedSQLException:SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [S1009]; error code [0]; --- The error occurred while applying a parameter map. --- Check the callEmpTreeList-InlineParameterMap. --- Check the statement (update procedure failed). --- Cause: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: [/quote]不对呀,这是传入参数为空的错误。 你什么也没传么[/quote] 肯定是传了,可能还是事务配置的问题
咖啡加糖_ 2014-02-26
  • 打赏
  • 举报
回复
引用 10 楼 fangmingshijie 的回复:
你换一种方式看看呢 <procedure id="callEmpTreeList" parameterMap="xxx"> {call Pro_GetEmpTreeList('4028804a274a8bb10128fd56877e4d44')} </procedure> <parameterMap id="xxx" class="HashMap" > 在这里把参数类型指明看看 </
我把xml改成 <procedure id="callEmpTreeList" parameterClass="java.lang.String"> {call Pro_GetEmpTreeList(#value#)} </procedure> java代码改成 getSqlMapClientTemplate().insert( "callEmpTreeList", "0"); 也是不行的, 参数传递应该是没问题的,可能还是事务配置的问题,但是我在网上找了下,无非就是<prop key="*">PROPAGATION_REQUIRED,readOnly</prop> 这段的问题,去掉还是不行...
  • 打赏
  • 举报
回复
你换一种方式看看呢 <procedure id="callEmpTreeList" parameterMap="xxx"> {call Pro_GetEmpTreeList('4028804a274a8bb10128fd56877e4d44')} </procedure> <parameterMap id="xxx" class="HashMap" > 在这里把参数类型指明看看 </
tony4geek 2014-02-26
  • 打赏
  • 举报
回复
感觉是事务的问题哦。
Defonds 2014-02-26
  • 打赏
  • 举报
回复
引用 7 楼 jimmy609 的回复:
[quote=引用 6 楼 defonds 的回复:] [quote=引用 5 楼 jimmy609 的回复:] [quote=引用 3 楼 defonds 的回复:] 你这样,以 string 传给 ibatis 试试:
<procedure id="callEmpTreeList" parameterClass="java.lang.String">
{call Pro_GetEmpTreeList(#str#)}
</procedure>
试过了 不行的 [/quote]这样写,报啥错[/quote] 一样的错误 org.springframework.jdbc.UncategorizedSQLException:SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [S1009]; error code [0]; --- The error occurred while applying a parameter map. --- Check the callEmpTreeList-InlineParameterMap. --- Check the statement (update procedure failed). --- Cause: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: [/quote]不对呀,这是传入参数为空的错误。 你什么也没传么
咖啡加糖_ 2014-02-26
  • 打赏
  • 举报
回复
引用 6 楼 defonds 的回复:
[quote=引用 5 楼 jimmy609 的回复:] [quote=引用 3 楼 defonds 的回复:] 你这样,以 string 传给 ibatis 试试:
<procedure id="callEmpTreeList" parameterClass="java.lang.String">
{call Pro_GetEmpTreeList(#str#)}
</procedure>
试过了 不行的 [/quote]这样写,报啥错[/quote] 一样的错误 org.springframework.jdbc.UncategorizedSQLException:SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [S1009]; error code [0]; --- The error occurred while applying a parameter map. --- Check the callEmpTreeList-InlineParameterMap. --- Check the statement (update procedure failed). --- Cause: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
Defonds 2014-02-26
  • 打赏
  • 举报
回复
引用 5 楼 jimmy609 的回复:
[quote=引用 3 楼 defonds 的回复:] 你这样,以 string 传给 ibatis 试试:
<procedure id="callEmpTreeList" parameterClass="java.lang.String">
{call Pro_GetEmpTreeList(#str#)}
</procedure>
试过了 不行的 [/quote]这样写,报啥错
咖啡加糖_ 2014-02-26
  • 打赏
  • 举报
回复
引用 3 楼 defonds 的回复:
你这样,以 string 传给 ibatis 试试:
<procedure id="callEmpTreeList" parameterClass="java.lang.String">
{call Pro_GetEmpTreeList(#str#)}
</procedure>
试过了 不行的
咖啡加糖_ 2014-02-26
  • 打赏
  • 举报
回复
引用 1 楼 fangmingshijie 的回复:
看看你的事务配置。
<props> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="execute*">PROPAGATION_REQUIRED,-BaseException</prop> <prop key="insert*">PROPAGATION_REQUIRED,-BaseException</prop> <prop key="create*">PROPAGATION_REQUIRED,-BaseException</prop> <prop key="update*">PROPAGATION_REQUIRED,-BaseException</prop> <prop key="delete*">PROPAGATION_REQUIRED,-BaseException</prop> <prop key="remove*">PROPAGATION_REQUIRED,-BaseException</prop> <prop key="import*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="pay*">PROPAGATION_REQUIRED,-BaseException</prop> <prop key="batch*">PROPAGATION_REQUIRED,-BaseException</prop> <prop key="*">PROPAGATION_REQUIRED,readOnly</prop> </props> 我把<prop key="*">PROPAGATION_REQUIRED,readOnly</prop> 这段去掉还是不行
Defonds 2014-02-26
  • 打赏
  • 举报
回复
你这样,以 string 传给 ibatis 试试:
<procedure id="callEmpTreeList" parameterClass="java.lang.String">
{call Pro_GetEmpTreeList(#str#)}
</procedure>
  • 打赏
  • 举报
回复
http://8792321.iteye.com/blog/961606
  • 打赏
  • 举报
回复
看看你的事务配置。

81,090

社区成员

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

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