SQLExecutor.getFirstResultSet goes into infinite loop -----------------------------------------------------
Key: IBATIS-384 URL: https://issues.apache.org/jira/browse/IBATIS-384 Project: iBatis for Java Issue Type: Bug Components: SQL Maps Affects Versions: 2.3.0, 2.2.0 Environment: Win XP, JDK 1.5 Reporter: Ravi Tummala Fix For: 2.3.1 SQLExecutor.getFirstResultSet method call goes into an infinite loop when using Stored procedures in MySQL db. The stored proc is very simple and nothing fancy. Let me know if you want me to send it to you. I will paste the SQLMap xml at the bottom here. While debugging into the IBatis 2.2 source, I found the following is always returning true in my case. private boolean moveToNextResultsIfPresent(Statement stmt) throws SQLException { boolean moreResults; // This is the messed up JDBC approach for determining if there are more results moreResults = !(((moveToNextResultsSafely(stmt) == false) && (stmt.getUpdateCount() == -1))); return moreResults; } I think other way to do this would be to do the following: This will avoid the infinite loop problem. I am not sure if this is the right approach anyways. private boolean moveToNextResultsIfPresent(Statement stmt) throws SQLException { boolean moreResults; if (!stmt.getConnection().getMetaData().supportsMultipleResultSets()) { return false; } moreResults = !(((stmt.getMoreResults() == false) && (stmt.getUpdateCount() == -1))); return moreResults; } Apparently, IBatis 2.1.6 works fine for us. It has the following: private boolean moveToNextResultSet(Statement stmt) throws SQLException { boolean moreResults; // This is the messed up JDBC approach for determining if there are more results moreResults = !(((stmt.getMoreResults() == false) && (stmt.getUpdateCount() == -1))); return moreResults; } *******************************SQLMap***************************** <parameterMap id="CheckPermissionParam" class="com.xyz.impl.PermissionCheckImpl"> <parameter property="username" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN" /> <parameter property="audioFileId" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN" /> <parameter property="permissionStatus" jdbcType="VARCHAR" javaType="java.lang.String" mode="OUT" /> <parameter property="returnErrorName" jdbcType="VARCHAR" javaType="java.lang.String" mode="OUT" /> <parameter property="returnCode" jdbcType="NUMBER" javaType="java.lang.Integer" mode="OUT" /> <parameter property="returnMessage" jdbcType="VARCHAR" javaType="java.lang.String" mode="OUT" /> </parameterMap> <procedure id="checkPermission" parameterMap="CheckPermissionParam" parameterClass="com.xyz.impl.PermissionCheckImpl"> {call pps_check_xyz_permission_pr(?,?,?,?,?,?)} </procedure> ******************************END SQLMap************************************************** thanks, Ravi -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira