|
Re: SQL Insert problem
|
Posted: Jul 9, 2002 9:18 AM
|
|
If you are working with JDBC version prior to 3.0 then you have only one solution and that is to execute a query to get the generated PK from order table. In this case , you may not have all columns values that can fetch you unique key value. However, in JDBC3.0, this problem has been solved and you can fetch the auto generated key values as follows.
your_statement.executeUpdate ( "insert into order ( your_column_name_list ) values ( your_values_list )", Statement.RETURN_GENERATED_KEYS ) ;
ResultSet rs = your_statement.getGeneratedKeys() ;
// Now your resultset rs will have the generated keys
For details , please refer to: http://java.sun.com/javaone/javaone2001/pdfs/1135.pdf
|
|