iBatis for Java [READ ONLY]
  1. iBatis for Java [READ ONLY]
  2. IBATIS-384

SQLExecutor.getFirstResultSet goes into infinite loop

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.0, 2.3.0
    • Fix Version/s: 2.3.5
    • Component/s: Core
    • Labels:
      None
    • Environment:
      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

      1. IBATIS-384.zip
        4 kB
        Kai Grabfelder

        Issue Links

          Activity

          Hide
          Kai Grabfelder added a comment -

          IBATIS-384.zip: project that shows the behaviour. It requires a mysql db running on localhost with a db named test and the following procedure

          CREATE PROCEDURE `RenewalProduct_JYS`(IN nProdC INT, OUT bReturn INT)
          BEGIN
          SET bReturn = nProdC;
          END;

          Show
          Kai Grabfelder added a comment - IBATIS-384 .zip: project that shows the behaviour. It requires a mysql db running on localhost with a db named test and the following procedure CREATE PROCEDURE `RenewalProduct_JYS`(IN nProdC INT, OUT bReturn INT) BEGIN SET bReturn = nProdC; END;
          Hide
          Kai Grabfelder added a comment -

          IBATIS-384 (SQLExecutor.getFirstResultSet goes into infinite loop)

          • implemented the suggested solution: if moveToNextResultsSafely returns false, and the driver does not support multiple result sets we return false even if the update count is not -1
          Show
          Kai Grabfelder added a comment - IBATIS-384 (SQLExecutor.getFirstResultSet goes into infinite loop) implemented the suggested solution: if moveToNextResultsSafely returns false, and the driver does not support multiple result sets we return false even if the update count is not -1
          Hide
          Kai Grabfelder added a comment -

          IBATIS-384.zip shows the issue, it requires a mysql database running on localhost with the following procedure

          CREATE PROCEDURE `RenewalProduct_JYS`(IN nProdC INT, OUT bReturn INT)
          BEGIN
          SET bReturn = nProdC;
          END;

          Show
          Kai Grabfelder added a comment - IBATIS-384 .zip shows the issue, it requires a mysql database running on localhost with the following procedure CREATE PROCEDURE `RenewalProduct_JYS`(IN nProdC INT, OUT bReturn INT) BEGIN SET bReturn = nProdC; END;

            People

            • Assignee:
              Unassigned
              Reporter:
              Ravi Tummala
            • Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development