I just started learning jdbc and doing various tests with it.
I came across the following situation
- set savepoint
- create prepared statement and try to execute(insert data into a table with foreign key value that doesn't exist
- the execute() method fails and I do a rollback.
- when I do a valid query a row is inserted into the db, but the primary key is set as n+2 instead of n+1(where n is the last inserted value). Guess the index autoincrements even though the query fails.
Is there a mechanism to avoid this and set n+1?
Note. I am using MySQL.
Thanks.