oracle 应用参数映射时 iBatis 错误 - 由 SQLException 引起:Cursor is closed

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3257433/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 21:02:33  来源:igfitidea点击:

iBatis error when applying parameter map - Caused by SQLException: Cursor is closed

sqloraclecursoribatis

提问by dpatchery

I am debugging an issue with a null ResultsMap returned from calling a stored procedure via iBatis for java. Here is a truncated copy of the exception I'm receiving.

我正在调试通过 iBatis for java 调用存储过程返回的 null ResultsMap 问题。这是我收到的异常的截断副本。

DataAccessException: Exception calling procedure
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException: 
--- The error occurred in ibatis-map.xml.  
--- The error occurred while applying a parameter map.  
--- Check the getEmpLoanDistribContribInfoMap.  
--- Check the output parameters (retrieval of output parameters failed).  
--- Cause: java.sql.SQLException: Cursor is closed.

I don't believe the problem is actually in the parameter map, since similar code works in other areas of the project, but I have included the parameter map and the stored proc header here just in case.

我不相信问题实际上出在参数映射中,因为类似的代码适用于项目的其他区域,但我在这里包含了参数映射和存储的 proc 头以防万一。

<parameterMap id="getEmpLoanDistribContribInfoMap" class="map" >
    <parameter property="resultCode" javaType="int" jdbcType="NUMERIC" nullValue="-1" mode="OUT"/>
    <parameter property="client_id" javaType="int" jdbcType="NUMERIC" mode="IN"/>
    <parameter property="emp_nbr" javaType="int" jdbcType="NUMERIC" mode="IN"/>
    <parameter property="general_info" javaType="result" jdbcType="ORACLECURSOR" mode="OUT"/> 
    <parameter property="current_contrib_info" javaType="result" jdbcType="ORACLECURSOR" mode="OUT"/> 
    <parameter property="future_contrib_info" javaType="result" jdbcType="ORACLECURSOR" mode="OUT"/> 
    <parameter property="distrib_info" javaType="result" jdbcType="ORACLECURSOR" mode="OUT"/> 
    <parameter property="loan_info" javaType="result" jdbcType="ORACLECURSOR" mode="OUT"/> 
</parameterMap>

function get_emp_ldc_info (
  client_id                 employees.clt_id%type,
  emp_nbr                   employees.emp_nbr%type,
  general_info              out retire_ref_types.retire_ref_cursor,
  current_contrib_info      out retire_ref_types.retire_ref_cursor,
  future_contrib_info       out retire_ref_types.retire_ref_cursor,
  distrib_info              out retire_ref_types.retire_ref_cursor,
  loan_info                 out retire_ref_types.retire_ref_cursor
) return number is
  retval number;

Each of the 5 cursors above are opened for selects within the body of the function. I extracted each select query, and all of them run properly (though some don't find any records -- could this be my problem?). I even created a script mirroring this function that defines each cursor in a declare block, and opens them. No exceptions are encountered.

上面 5 个游标中的每一个都为函数体中的选择打开。我提取了每个选择查询,并且所有查询都正常运行(尽管有些没有找到任何记录——这可能是我的问题吗?)。我什至创建了一个脚本来反映这个函数,它在一个声明块中定义每个游标,并打开它们。没有遇到异常。

I realize my problem could very well be bad data, but I am not sure where to look. The only thing I can think of is that I shouldbe getting this exception if one of the out cursors in the parameter map is opened for a select that finds no data. Does anyone know if this is true?

我意识到我的问题很可能是坏数据,但我不知道去哪里找。我唯一能想到的是,如果为找不到数据的选择打开了参数映射中的一个输出游标,我应该会收到此异常。有没有人知道这是不是真的?

采纳答案by dpatchery

I have confirmed that it was bad data causing this. I still haven't found where it is, but I'm answering the question so nobody wastes their time on this. Thanks for reading.

我已经确认这是导致这种情况的错误数据。我仍然没有找到它在哪里,但我正在回答这个问题,所以没有人在这上面浪费时间。谢谢阅读。