Details
-
New Feature
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Won't Do
-
3.3.2
-
None
Description
It would be preferable if the ResultSet returned by getGeneratedKeys() provided the name of the table columns with ResultSet.getMetaData().getColumnName(int index) rather than insert_id
Otherwise it assumes that we already know the name of the column which is the primary key!
In any case this does not follow the JDBC specifications.
see: Statement.java
mysql/mariadb protocol doesn't know auto_increment column name when inserting data.
mysql driver return by default "GENERATED_KEY" while mariadb driver return "insert_id".
The only solution would be to parse command, extract table name and search for auto_increment field. That would be costly in terms of performance.
Since MariaDB/MySQL can have only one auto_increment field, retrieving value using getLong(0) or getLong("insert_id") in place of getLong("<my real column name>") with connector command parsing + an additional round trip seems a bit too much just to be rigorous.
I understand that this is not perfect, but better than the alternative