Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Fixed
-
1.5.7
-
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 |
}
|
}
|
}
|
}
|