Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-1144

Unexpected ResultSet Object exception thrown when calling stored procedure using prepared statement

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 3.3.0, 3.3.1, 3.3.2
    • None
    • JDBC compatibility
    • None
    • temurin-17.04 java version "17.0.9"
      MariaDB Community Server 10.6.16

    Description

      I have a database connection that creates a stored procedure in the attached file. The stored procedure has one input parameter and several output parameters. It does multiple inserts into a table and then selects data from the table in this example.

      In code, we take the database connection and create a prepared call, set the parameters, and then execute the statement.

      When using the 2.7.11 JDBC driver, this works just fine without a problem, but when upgrading from 2.x to 3.x, we get a SQLException: "the given SQL statement produces an unxpected ResultSet object".

      This exception is coming from the ServerPreparedStatement.executeLargeUpdate() method of the driver. After a bit of debugging I found that the results list that is populated after the execution has one or more Result objects, and then the last item in the list is the OkPacket. This method is expecting the OkPacket to be the first item in the list not the last causing this problem. If I fork the code and change the line from:
      currResult = results.remove(0);
      to:
      currResult = results.remove(results.size() - 1);

      The call to the stored procedure executes and returns successfully.

      I am not sure if the results list always has the OkPacket as the last result in this list, so I am not sure if this change would work in all cases.

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            bshapiro Ben Shapiro
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.