You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by "Venning, Christian " <ch...@citi.com> on 2009/07/16 14:31:42 UTC

Call stored proc that returns result set and populates OUT param

Hi all,
 
I have a stored procedure that returns one result set and populates one
OUTPUT parameter and I am trying to call this from java (1.5) using
iBatis (version 2.3.0.677) via Spring (2.5.3). I have tried looking on
the internet and browsing the documentation on this but am not managing
to get it right, so hopefully somebody here might be able to point me in
the right direction or see what I'm doing wrong.
 
So far, I have something like this:
 
 <resultMap id="myResult" class="com.dummy.MyResult">
     <result property="name" column="NAME" />
     <result property="age" column="AGE" />
     <result property="shoeSize" column="SHOE_SIZE" />
 </resultMap>
 
 <parameterMap id="myProcParams" class="java.util.Map">
     <parameter property="dummy" jdbcType="VARCHAR"
javaType="java.lang.String" mode="IN" />
     <parameter property="myOut" jdbcType="INT"
javaType="java.lang.Integer" mode="OUT" />
 </parameterMap> 
 
 <procedure id="myProc" parameterMap="myProcParams"
resultMap="myResult">
     {call DoStuff(?,?)}
 </procedure>
 
My java looks like this:
 
 public List<MyResult> doStuff() {
  
    Map<String, Object> params = new HashMap<String, Object>();
  
    params.put("dummy", "Hello");
    params.put("myOut", new Integer(0));
  
    List<MyResult> myResults = getSqlMapClientTemplate()
        .queryForList("myProc", params);
  
    System.out.println((Integer) params.get("myOut"));
  
    return myResults;
 }
 
But I'm getting this when my java runs:
 
org.springframework.jdbc.UncategorizedSQLException: SqlMapClient
operation; uncategorized SQLException for SQL []; SQL state [HY092];
error code [0];   
--- The error occurred in ibatis/maps/common/blah.xml.  
--- The error occurred while executing query procedure.  
--- Check the {call DoStuff(?,?)}.  
--- Check the output parameters (register output parameters failed).  
--- Cause: java.sql.SQLException: Invalid java.sql.Types constant value
-99999999 passed to set or update method.; nested exception is
com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in ibatis/maps/common/blah.xml.  
--- The error occurred while executing query procedure.  
--- Check the {call DoStuff(?,?)}.  
--- Check the output parameters (register output parameters failed).  
--- Cause: java.sql.SQLException: Invalid java.sql.Types constant value
-99999999 passed to set or update method.
 at
org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translat
e(SQLStateSQLExceptionTranslator.java:124)
 at
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.tran
slate(SQLErrorCodeSQLExceptionTranslator.java:322)
 at
org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClient
Template.java:212)
 at
org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResul
t(SqlMapClientTemplate.java:249)
 at
org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapC
lientTemplate.java:296)
 
Can anybody see what I'm doing wrong?
 
Regards,
Christian Venning