[CONJ-316] Wrong Exception thrown for ScrollType TYPE_SCROLL_INSENSITIVE: Invalid operation for result set type TYPE_FORWARD_ONLY Created: 2016-06-25  Updated: 2016-06-30  Resolved: 2016-06-30

Status: Closed
Project: MariaDB Connector/J
Component/s: Failover
Affects Version/s: 1.4.6
Fix Version/s: 1.5.0-RC

Type: Bug Priority: Critical
Reporter: Leonard Lin Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

Oracle Java 1.8u92
MariaDB 10
Connector/J 1.4.6 (reproducible with 1.4.5 too)



 Description   

I wrote a Unit-Test to demonstrate exception

@Test
    public void scrollScrollableResultTest() throws SQLException {
        insertRows(2);
        PreparedStatement stmt = sharedConnection.prepareStatement("SELECT * FROM result_set_test", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
        stmt.setFetchSize(2);
        ResultSet rs = stmt.executeQuery();
        try {
        	rs.beforeFirst();
        	assertTrue(true);
        } catch(SQLException sqle) {
        	fail("beforeFirst() should work on a TYPE_SCROLL_INSENSITIVE result set");
        } finally {
        	stmt.close();
        	rs.close();
        }
    }

This test will fail.
Our ERP application failed with the maria driver but worked with the mysql driver and it took us a while figuring out why.

Reading through the code I found that mariaDb driver ignores the scroll-type, since it's always "SCROLL_INSENSITIVE".
This is fine, however other parts of the driver do make the distinction.

a unit-test and "workaround" hack has been written and will create a pull-request for discussion.
It is a hack, better would be to implement the scroll-type information.



 Comments   
Comment by Diego Dupin [ 2016-06-30 ]

You're right.
Thanks for your PR, but this was more a workaround than a correction as you indicated, so i didn't commit it.
Issue fixed with https://github.com/MariaDB/mariadb-connector-j/commit/ab052062aef38cc32bf6824f70686632169f2546.
Will be with 1.5 release.

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