java - Incorrect integer value:'javax.swing.JFormattedtextField -


i have problem , want ask you. doing netbeans , here code :

private void jbutton_suaactionperformed(java.awt.event.actionevent evt) {                                                     // todo add handling code here:         string sql ="update mathang set tenmathang = ?, donvitinh = ?, quycach = ?, dongiaban = ?, manhomhang = ? mamathang = ?";         string jf = jformattedtextfield_dongiaban.gettext();         int = integer.parseint(jf);         //abstractformatter formatter = jf.getformatter();         try{             pst =conn.preparestatement(sql);             rs =pst.executequery();             pst.setstring(1, jtextfield_tenmathang.gettext());             pst.setstring(2, jtextfield_donvitinh.gettext());             pst.setstring(3, jtextfield_quycach.gettext());             pst.setstring(4, i);             pst.setstring(5, (string) jcombobox_manhomhang.getselecteditem());             //jcombobox_manhomhang.additem(jtable_mathang.gettext());             //pst.setstring(5, jcombobox_manhomhang.setselecteditem());             //(2, jcombobox_manhomhang.gettext());             pst.setstring(6, jtextfield_mamathang.gettext());             pst.executeupdate();             joptionpane.showmessagedialog(null, "Đã cập nhật bảng  < mẶt hÀng >");             updatemathang();         }catch(sqlexception | headlessexception e){             joptionpane.showmessagedialog(null, e);         }     }  

the error : java.sql.sqlexception: incorrect integervalue:'javax.swing.jformattedfield[jformattedfield...layout=javax.swing.plaf.basic.basictextui$updatehandler,alignmentx=0.0,alignme' column path @ row1

thanks reading!

i notice few issues,

pst =conn.preparestatement(sql); // rs =pst.executequery(); // <-- bind parameters first! pst.setstring(1, jtextfield_tenmathang.gettext()); pst.setstring(2, jtextfield_donvitinh.gettext()); pst.setstring(3, jtextfield_quycach.gettext()); pst.setint(4, i); // <-- setint - not setstring() pst.setstring(5, jcombobox_manhomhang.getselecteditem()     .tostring()); // <-- call tostring() instead of cast. //jcombobox_manhomhang.additem(jtable_mathang.gettext()); //pst.setstring(5, jcombobox_manhomhang.setselecteditem()); //(2, jcombobox_manhomhang.gettext()); pst.setstring(6, jtextfield_mamathang.gettext()); pst.executeupdate(); // <-- looks good. 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -