Friday, October 17, 2003 11:50 AM
First, You need to create your PK column in MySQL with the auto_increment keyword.
Then, you need to omit the PK column from the INSERT statement, like this:
INSERT INTO my_table (non-pk-col1, non-pk-col2, ...) VALUES (...)
MySQL will automatically generate the PK for you. If you're using JDBC 3.0 (I think... maybe it's 2.0), you can use the
PreparedStatement.getGeneratedKeys method to determine the new PK created.
Hope that helps,