Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
3.3.1
-
None
Description
The bug involves a NullPointerException being thrown when calling the getGeneratedKeys() method on a Statement object after executing an executeBatch() operation in a JDBC application using the MariaDB connector.
This behavior is inconsistent with the MySQL JDBC connector, where no such exception is thrown under similar circumstances, suggesting a potential bug in the MariaDB JDBC connector.
In addition, if I change the first batch SQL to "INSERT INTO table5_0 VALUES(16, -601)", which does not violate the constraint, getGeneratedKeys() will not throw NullPointerException, too.
@Test
|
public void test() throws SQLException { |
Connection con = null; |
Statement stmt = null; |
ResultSet rs = null; |
con = DriverManager.getConnection("jdbc:mariadb://localhost:3366/test5?user=user&password=password"); |
|
stmt = con.createStatement();
|
stmt.executeUpdate("CREATE TABLE table5_0(id SMALLINT PRIMARY KEY,value BIGINT);"); |
|
stmt = con.createStatement();
|
stmt.addBatch("INSERT INTO table5_0 VALUES(1679640894, -601)"); |
stmt.addBatch("UPDATE table5_0 SET value = 226 WHERE id <= 0"); |
try { |
stmt.executeBatch();
|
} catch (Exception e) { |
System.out.println(e);
|
}
|
|
try { |
rs = stmt.getGeneratedKeys(); // java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because "this.results" is null |
} catch (Exception e) { |
System.out.println(e);
|
}
|
}
|