Michael Lugo
Michael Lugo

Reputation: 55

SQLException "No value specified for parameter 3"

I am not receiving this error with the edit button but I am receiving it when I press the save button. It seems like all my parameters are there but maybe I am missing something. I've combed over the code for the save button over and over again but can't seem to understand whats wrong.What I want it to do is overwrite the data for a specific record according to the user input for part number and due date.

 PreparedStatement myquery3;             
 String InsertQuery3 = " UPDATE TABLE AllRecords SET DueDate = ? WHERE WorkOrderID = ?"
                        + "values(?,?)";                    
 myquery3 = conn.prepareStatement(InsertQuery3);
 myquery3.setString(1, duedate);
 myquery3.setString(2, workorder);
 myquery3.execute();

Upvotes: 2

Views: 7862

Answers (1)

nano_nano
nano_nano

Reputation: 12523

this is the problem:

String InsertQuery2 = "UPDATE TABLE Sample SET PartNumber = ? WHERE WorkOrderID = ?"
                            + "values(?,?)";                    
                myquery2 = conn.prepareStatement(InsertQuery2);
                myquery2.setString(1, partnumber);
                myquery2.setString(2, workorder);
                myquery2.execute(); 

you define 4 placeholder but only two are set.

you did the same mistake for InsertQuery3.

as a side note. the correct update sql looks like: update table fubar set col1 = ? where id = ?

values is used for insert

Upvotes: 6

Related Questions