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

ResultSet.absolute should not always return true

    XMLWordPrintable

    Details

      Description

      ResultSet.absolute always returns true, which is contrary to the spec as for instance beyond the end of the result set it must return false (and also in other circumstances).

      Example unit test that fails:

      import static org.junit.Assert.assertFalse;
       
      import java.sql.Connection;
      import java.sql.DatabaseMetaData;
      import java.sql.DriverManager;
      import java.sql.ResultSet;
      import java.sql.Statement;
       
      import org.junit.After;
      import org.junit.Before;
      import org.junit.Test;
       
      public class TestResultSetAbsolute {
       
          public static final String URL = "jdbc:mysql://localhost:3306/mysql?user=mysq&password=secret";
       
          public Connection connection;
       
          @Before
          public void setUp() throws Exception {
              connection = DriverManager.getConnection(URL);
          }
       
          @After
          public void tearDown() throws Exception {
              connection.close();
          }
       
          @Test
          public void testResultSetAbsolute() throws Exception {
              try (Statement statement = connection.createStatement()) {
                  statement.execute("DROP TABLE IF EXISTS testfoo");
                  statement.execute("CREATE TABLE testfoo(i int)");
                  try (ResultSet rs = statement.executeQuery("SELECT i FROM testfoo")) {
                      // the following fails with MariaDB Connector/J, but works with MySQL Connector/J
                      assertFalse(rs.absolute(42)); // beyond end so available should be false
                  }
              }
          }
      }
      

        Attachments

          Activity

            People

            Assignee:
            diego dupin Diego Dupin
            Reporter:
            fguillaume Florent Guillaume
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: