1. Taro L. Saito
  2. sqlite-jdbc
  3. Issues
Issue #59 invalid

PreparedStatement getGeneratedKeys is not working

Anonymous created an issue

INSERT command is working, but then it doesn't return any key generated

Example: int key = 0; PreparedStatement ps = null; ResultSet keys = null;

ps = connection.prepareStatement("insert XXXXXXXXXXXXX");


        keys = ps.getGeneratedKeys();

        key = keys.getInt(1);


Comments (4)

  1. Radek Gabiga

    I can confirm that too, as well as its inconsistency. I've got few tables in the DB, with most of them having

    id integer PRIMARY KEY NOT NULL

    In my code I use getGeneratedKeys() on two of them and on one it works, on the other - I get a null ResultSet. I don't think the tables have significant differences between themselves. Both of them have some fields referencing other tables, some unique constraints etc. Manually executing SELECT last_insert_rowid() works fine.

    Tested on 3.7.15 from couple months ago (probably SNAPSHOT, from Maven) and today on 3.7.15-M1 (also from Maven).

  2. Log in to comment