Uploaded image for project: 'iBatis for Java [READ ONLY]'
  1. iBatis for Java [READ ONLY]
  2. IBATIS-384

SQLExecutor.getFirstResultSet goes into infinite loop

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.0, 2.3.0
    • 2.3.5
    • Core
    • None
    • Win XP, JDK 1.5

    Description

      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 and is thus causing the getFirstResultSet method to go in an infinite while loop.

      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

      Attachments

        1. IBATIS-384.zip
          4 kB
          Kai Grabfelder

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rtummala Ravi Tummala
              Votes:
              2 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: