I found a few duplicate threads talking about using option innodb_autoinc_lock_mode=0 but I don't know how to do that in SQLite.
Here is my code:
ps = conn.prepareStatement("INSERT OR IGNORE INTO users(name, lastname) VALUES(?, ?)");
ps.setString(1, nameField.getText());
ps.setString(2, lastNField.getText());
int res = ps.executeUpdate();
name and lastname are set as unique keys. This works as expected (doesn't insert if name and last name already exist) but autoincrements my id every time. Any idea how to approach this by either fixing the autoincrement or changing the sql code? I'm doing this in java.
Aucun commentaire:
Enregistrer un commentaire