Bug #21091 getGeneratedKeys() problem
Submitted: 17 Jul 2006 9:40 Modified: 31 Mar 2014 11:48
Reporter: Herv THIRY Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:3.1.13 OS:Any
Assigned to: Alexander Soklakov CPU Architecture:Any

[17 Jul 2006 9:40] Herv THIRY
Description:
When performing an insert with an auto-increment column, the stament.getGeneratedKeys() returns an empty resultset whereas the line is correctly inserted in the table.
The table is using NDB engine with no tablespace, the server is MySQL 5.1.11 beta icc for Linux 32bit.

How to repeat:
PreparedStatement statement = connection.prepareStatement(<<sql insert request>>, Statement.RETURN_GENERATED_KEYS);
statement.setString(key, value);
....
/* You naturally do not define the auto-increment column */
statement.executeUpdate();
ResultSet rs = statement.getGeneratedKeys();
while(rs.next())
   System.out.println(rs.getInt(1));

/* The result set is empty, whereas the line is correctly inserted */
[18 Jul 2006 0:13] Mark Matthews
Does it fail with a different storage engine? Does "SELECT LAST_INSERT_ID()" work when this method does not?
[18 Aug 2006 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[31 Mar 2014 11:48] Alexander Soklakov
I close this report as "Can't repeat" because there is no feedback for a long time and codebase is too old. Please, feel free to reopen it if the problem still exists in current driver.