Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
3.0.3
-
None
Description
In version 2.6.1 there is no problem. But with mariadb-java-client 3.0.3 there is.
Here is a negative test to describe the problem. Mind you that you need a working connection for the test to work and this example code does not close anything to keep things simple.
rs.next() should return false, because getGeneratedKeys() API documentation says
"If this Statement object didnot generate any keys, an empty ResultSetobject is returned."
Instead, with the new version it returns true, and value 0 is returned when no keys are generated.
@Test |
public void testGetKeys() throws SQLException { |
ds = getDataSource();
|
conn = ds.getConnection();
|
Statement stmt = conn.createStatement();
|
stmt.execute("CREATE TABLE IF NOT EXISTS `KEYTEST` (`id` INT(11) NOT NULL);"); |
PreparedStatement ps = conn.prepareStatement("INSERT INTO `KEYTEST`(`id`) VALUES(5);", Statement.RETURN_GENERATED_KEYS); |
ps.execute();
|
ResultSet rs = ps.getGeneratedKeys();
|
assertTrue(rs.next());
|
assertEquals(0, rs.getInt(1)); |
}
|