I have below,
-
Student.java -> contains method to add Students in the database
addStudent(int id, String name,String address,String class) -
AddStudentServlet.java -> Controller to interact with the db and jsp
- AddStudent.jsp -> JSP form to add students
- Student table in mysql with columns id, name, address, class
When I submit the form with all values its fine. However when I enter partial values ie. in id, name fields, I get an error saying number of parameters do not match.
How can I change the model to allow partial addition of fields in the db?
It seems that in your
DAOthis error is being thrown bydatabasewhereinsert in to @tablenameyou have less number of column values. i.e. you have defined 4 column but passing values 3 only.how can i change the model to allow partial addition of fields in the db?In insert SQL pass those column as null if they are not entered in form but keep complete insert statement