mysql - Exception "Parameter index out of range (1 > number of parameters, which is 0)." -
query="insert paint_inventory(id,name,type,gallons,quarters) values(?,?,?,?,?)"; con.preparestatement(query); pstm.setint(1,integer.parseint(itemid_newitem_field.gettext())); pstm.setstring(2,name_newitem_field.gettext()); pstm.setstring(3,type_newitem_field.gettext()); pstm.setint(4,integer.parseint(gallons_quantity_newitem_field.gettext())); pstm.setint(5,integer.parseint(quarters_quantity_newitem_field.gettext())); pstm.execute(); joptionpane.showmessagedialog(rootpane,"item has been registered");
pstm
defined in code? hope need assign preparestatement
pstm
can set parameter values.
also ensure pstm
not used preparestatement
in same method or other methods. each preparestatement
should have separate variable name set parameter values.
query="insert paint_inventory(id,name,type,gallons,quarters) values(?,?,?,?,?)"; pstm = con.preparestatement(query); -- assign pstm set values ... ...
Comments
Post a Comment