[CONJ-415] ResultSet.absolute should not always return true Created: 2017-01-25  Updated: 2017-02-09  Resolved: 2017-02-09

Status: Closed
Project: MariaDB Connector/J
Component/s: JDBC 4.2 compatibility
Affects Version/s: 1.5.7
Fix Version/s: 1.5.8

Type: Bug Priority: Minor
Reporter: Florent Guillaume Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None


 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
            }
        }
    }
}



 Comments   
Comment by Diego Dupin [ 2017-02-09 ]

Correction done with commit : https://github.com/MariaDB/mariadb-connector-j/commit/40f2ccfe69fb7fd63ca96a55f67dae5f9fa08070

Snapshot is available using :

<repositories>
    <repository>
        <id>sonatype-nexus-snapshots</id>
        <name>Sonatype Nexus Snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
</repositories>
 
<dependencies>
    <dependency>
        <groupId>org.mariadb.jdbc</groupId>
        <artifactId>mariadb-java-client</artifactId>
        <version>1.5.8-SNAPSHOT</version>
    </dependency>
</dependencies>

thanks for reporting issue !

Generated at Thu Feb 08 03:15:29 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.