[CONJ-1127] Statement.getResultSetType () seems failed to change the result set type Created: 2023-11-18  Updated: 2023-11-22  Resolved: 2023-11-22

Status: Closed
Project: MariaDB Connector/J
Component/s: JDBC compatibility, metadata
Affects Version/s: 3.3.0
Fix Version/s: 3.3.1

Type: Bug Priority: Major
Reporter: Wenqian Deng Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None


 Description   

@Test
public void test() throws SQLException {
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    con = DriverManager.getConnection("jdbc:mariadb://localhost:3366/test69?user=user&password=password");
    stmt = con.createStatement(1004, 1008, 2);
    stmt.addBatch("DROP TABLE IF EXISTS table0_0;");
    stmt.addBatch("CREATE TABLE table0_0(id INT AUTO_INCREMENT PRIMARY KEY,value INT);");
    stmt.addBatch("INSERT INTO table0_0 VALUES(1, -179653912)");
    stmt.addBatch("INSERT INTO table0_0 VALUES(2, 1207965915)");
    stmt.executeBatch();
    stmt.executeUpdate("INSERT INTO table0_0 (value) VALUES(667711856)", Statement.RETURN_GENERATED_KEYS);
    rs = stmt.getGeneratedKeys();
    System.out.println(stmt.getResultSetType()); // 1004
    System.out.println(rs.getType()); // 1003
}

When a Statement is created with a specific ResultSet type 1004, the expectation is that any ResultSet derived from this Statement should have the same type. However, in the provided test case, the ResultSet obtained from getGeneratedKeys() reports a type of ResultSet.TYPE_FORWARD_ONLY (1003), which is inconsistent with the type specified when creating the Statement.



 Comments   
Comment by Diego Dupin [ 2023-11-22 ]

thanks for reporting that issue.
This is indeed a bug, and metadata resultset's type are wrong either (TYPE_FORWARD_ONLY in place of TYPE_SCROLL_INSENSITIVE).
corrected with https://github.com/mariadb-corporation/mariadb-connector-j/commit/fb673c2299bd6fefcb54d972f2f073ee466f4918

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