If you are doing an UPDATE the record must already exist in your table.
Roughly your application needs the following process:
- Read the record from the database
- Put data from the record into your GUI controls and also keep the ID value somewhere.
- Now the user hits "Save": You transfer the values from GUI controls into your PreparedStatement and use the ID from step 2 to build the where parameter.
- Commit.
If you want to create a new record, you skip step 1 and therefore have no ID value.
Then instead of doing an UPDATE in step 3 you will need to do a INSERT.