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

Current position is after the last row

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 2.6.2
    • N/A
    • aurora
    • None
    • AWS Aurora MySQL 5.6

    Description

      Hi there,

      not really a bug but this looks like the best place to ask and I am a bit lost.

      I am regulary seeing a "Current position is after the last row" SQLException in my production logs. I have no idea why they happen and I am unable to reproduce the error on my local machine. In addition, this exception does not happen every time. Just a small fraction within thousands of other statements that do work.

      Unfortunately reading the source code didn't help me much either. I know why the error happens, but I don't understand why this situation even occurs. rowPointer >= dataSize should never happen.

      Here are the steps I do in production

      • connection.prepareStatement("SELECT * FROM Table WHERE Id = ? FOR UPDATE",
        ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE)
      • Next I check the ResultSet (rs) returned from executeQuery
      • If rs.next() is true
      • I might do an rs.updateRow()
      • If rs.next() is false
      • rs.moveToInsertRow(), some rs.updateXZY and followed by rs.insertRow()

      In summary I do a insert row if it doesn't exist otherwise I might update the row.

      Any ideas how to narrow this one down?

      Attachments

        Activity

          diego dupin Diego Dupin added a comment -

          Having the complete stackTrace would help narrowing issue at least

          The only way i see to get this kind of error is moving during insert.
          An example :

                 rs.moveToInsertRow(); // moves cursor to the insert row
                 rs.updateString(1, "AINSWORTH"); // updates the
                    // first column of the insert row to be AINSWORTH
                 rs.updateInt(2,35); // updates the second column to be 35
                 rs.updateBoolean(3, true); // updates the third column to true
                 rs.insertRow();
                 rs.moveToCurrentRow();
          

          moving cursor with methods like next, absolute, ... after moveToInsertRow(), but before insertRow() might result in that kind of state.

          diego dupin Diego Dupin added a comment - Having the complete stackTrace would help narrowing issue at least The only way i see to get this kind of error is moving during insert. An example : rs.moveToInsertRow(); // moves cursor to the insert row rs.updateString( 1 , "AINSWORTH" ); // updates the // first column of the insert row to be AINSWORTH rs.updateInt( 2 , 35 ); // updates the second column to be 35 rs.updateBoolean( 3 , true ); // updates the third column to true rs.insertRow(); rs.moveToCurrentRow(); moving cursor with methods like next, absolute, ... after moveToInsertRow(), but before insertRow() might result in that kind of state.

          Hi Diego,

          apologies. I don't think there is an issue with the driver. It looks like just some programming bug. There was no check wether or not rs.next() does actually return true. It was just assumed. Hence the error message.

          Again, I am very sorry. Not a bug. Please close this issue.

          raupach Björn Raupach added a comment - Hi Diego, apologies. I don't think there is an issue with the driver. It looks like just some programming bug. There was no check wether or not rs.next() does actually return true. It was just assumed. Hence the error message. Again, I am very sorry. Not a bug. Please close this issue.
          diego dupin Diego Dupin added a comment -

          better this way .
          closing now

          diego dupin Diego Dupin added a comment - better this way . closing now

          People

            diego dupin Diego Dupin
            raupach Björn Raupach
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

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