I am using HXTT DBF v3.1 and I want to get the last_Insert autoincrement primary key from a table in a transaction that is not end yet. It is possible in MySQL. So I would like to ask if it is possible with your driver or Foxpro. If yes how I can do it.
My database is in Foxpro 8
|
First, you need have an AUTO_INCREMENTcolumn.
Secondly, you should use Statement.RETURN_GENERATED_KEYS. For instance,
stmt.executeUpdate("insertsql;",Statement.RETURN_GENERATED_KEYS);
ResultSet rs=stmt.getGeneratedKeys();
rs.next();
System.out.println("The id for inserted row is "+rs.getObject(1));
|
What is insertsql? Is it the SQL statement I am going to insert in the table?
|
Yeah. But you should make sure there's an AUTO_INCREMENTcolumn in your table.
|