应用参数映射时 iBatis 错误 - Caused by SQLException: Cursor is close
我正在调试通过 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.
我不认为问题实际上出在参数映射中,因为类似的代码也适用于项目的其他区域,但我在这里包含了参数映射和存储的过程标头,以防万一。
<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;
上面的 5 个光标中的每一个都会打开,以便在函数体内进行选择。我提取了每个选择查询,并且所有查询都正常运行(尽管有些没有找到任何记录 - 这可能是我的问题吗?)。我什至创建了一个镜像此函数的脚本,该脚本在声明块中定义每个游标并打开它们。没有遇到任何异常。
我意识到我的问题很可能是坏数据,但我不知道该去哪里寻找。我唯一能想到的是,如果为没有找到数据的选择打开参数映射中的输出游标之一,我应该会收到此异常。有谁知道这是真的吗?
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.
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.
<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.
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 should be 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经确认这是由错误数据引起的。我还没找到它在哪里,但我正在回答这个问题,所以没有人在这上面浪费时间。感谢您的阅读。
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.