Prepare an INSERT statement with parameters that include a VARCHAR(32). The orderDetailId (which in this case is a 32-character string) should be passed in full to the database, and the foreign key ...
The problems with PreparedStatement stem from its syntax for parameters. Parameters are anonymous and accessed by index as in the following: PreparedStatement p = con.prepareStatement("select * from ...