java - SQLException Parameter index out of range -
What am I doing wrong in this code? This gives a SQLException that a parameter is out of range, while I think I have given the parameter. Type the item type as
try {string sql = "item type", in the form of 'med by' by MD_, as a 'model' model, 'selling price As' Purchase Price ',' + "purchase_date as' purchase date ',' voucher no 'to' vouchers' as' sale_price, 'as purchase. As, "+" the voucher date as the voucher date, as record_no 'record number'. "+" Where to buy vouch_no =? "; Ps.setInt (1, integer. PRIIST (txt_vouchno_p.getText ()); Ps = con.prepareStatement (SQL); Rs = ps.executeQuery (); Table_p.setModel (DbUtils.resultSetToTableModel (RS));} Hold (pre-SQLException) {JOptionPane.showMessageDialog (empty, "error:" + east);} hold (exception before) {JOptionPane.showMessageDialog (zero, "error:" + east);} Your order for calling methods is wrong First of all, you prepare the statement, then you set the bound variable value. Change ps.setInt (1, Full .piIINt (txt_vouchno_p.getText ()); Ps = con.prepareStatement (SQL); From to
ps = con.prepareStatement (sql) ; Ps.setInt (1, integer. PRIIST (txt_vouchno_p.getText ());
Comments
Post a Comment