当前位置: 代码迷 >> Oracle技术 >> ibatis oracle 调用存储过程 无法取得返回值,该怎么解决
  详细解决方案

ibatis oracle 调用存储过程 无法取得返回值,该怎么解决

热度:119   发布时间:2016-04-24 08:29:52.0
ibatis oracle 调用存储过程 无法取得返回值
java 
  Map map = new HashMap();
  map.put("respCode", "100");
  getSqlMapClientTemplate().insert("getPhotos",map);
  return (String)map.get("respCode");
-----------------------
xml
  <parameterMap class="map" id="swapParameters">  
  <parameter property="respCode" javaType="java.lang.String" jdbcType="varchar2" mode="OUT"/>  
</parameterMap>  
  <procedure id="getPhotos" parameterMap="swapParameters" >
  {call getPhoto(?)}
  </procedure>
---------------------------
oracle sql
create or replace procedure getPhoto(respCode out varchar2)
as
begin
  respCode := 'aaa';
end;

===============================================================
org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation: encountered SQLException [  
--- The error occurred in com/rm/yjzq/dao/impl/sql/yjzq.xml.  
--- The error occurred while executing update procedure.  
--- Check the {call getPhoto(?)}.  
--- Check the output parameters (register output parameters failed).  
--- Cause: java.sql.SQLException: 无效的列类型: -99999999]; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:  
--- The error occurred in com/rm/yjzq/dao/impl/sql/yjzq.xml.  
--- The error occurred while executing update procedure.  
--- Check the {call getPhoto(?)}.  
--- Check the output parameters (register output parameters failed).  
--- Cause: java.sql.SQLException: 无效的列类型: -99999999
com.ibatis.common.jdbc.exception.NestedSQLException:  
--- The error occurred in com/rm/yjzq/dao/impl/sql/yjzq.xml.  
--- The error occurred while executing update procedure.  
--- Check the {call getPhoto(?)}.  
--- Check the output parameters (register output parameters failed).  
--- Cause: java.sql.SQLException: 无效的列类型: -99999999


求高手急救,在网上找了很多的例子,但是都不是正确的,只好发帖求教。
原来是一个入参一个出参,现在直接出参还是不对。


------解决方案--------------------
对java不是很了解。不过这里看起来,本来应该用一个变量来获取存储过程中传出参数respCode的值,但你的?这里不能代表一个变量吧
这个地方还不如改成函数
------解决方案--------------------
jdbcType="varchar2" 错了 jdbcType="VARCHAR"

jdbc里面没有varchar2 这里的VARCHAR不是数据库类型,是指java.sql.Types.VARCHAR
代码迷推荐解决方案:oracle存储过程,http://www.daimami.com/search?q=177537
  相关解决方案