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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -