日期:2014-05-17  浏览次数:20769 次

ibatis调用mysql存储过程出错,求解?
错误信息为:
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')是没有问题的,


求解........

------解决方案--------------------
看看你的事务配置。
------解决方案--------------------
http://8792321.iteye.com/blog/961606

------解决方案--------------------
你这样,以 string 传给 ibatis 试试:
<procedure id="callEmpTreeList" parameterClass="java.lang.String">
{call Pro_GetEmpTreeList(#str#)}
</procedure>

------解决方案--------------------
引用:
Quote: 引用:

你这样,以 string 传给 ibatis 试试:
<procedure id="callEmpTreeList" parameterClass="java.lang.String">
{call Pro_GetEmpTreeList(#str#)}
</procedure>

试过了 不行的  
这样写,报啥错
------解决方案--------------------