java.sql.SQLException参数索引超出范围(2>参数个数,为1)

时间:2014-10-15 12:14:59

标签: java sql database

private void jbx_ItemPopupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {                                                      
       try{
          conn=ShopDb.database();
          con2=ShopDb.database();
        String cth_item=(String) jbx_Item.getSelectedItem();
       comboUpdate(cth_item);

      String quary2="select qunine from stock where itemID = ? ";

     stm2=con2.prepareStatement(quary2);
     stm2.setString(1,cth_item);
     res2=stm2.executeQuery(); 
    if(res2.next()){
  Double fil2= res.getDouble("quninew");

   String valu = Double.toString(fil2);
   txtBill_availailty.setText(valu);
    }


   }catch(SQLException e){
   JOptionPane.showMessageDialog(null,e);
   }



}                        

2 个答案:

答案 0 :(得分:1)

您正在获取奎宁并从结果集中检索奎宁。先修复它,然后检查问题是否存在,否则提供堆栈跟踪。

答案 1 :(得分:1)

你能做到吗

Double fil2= res.getDouble("qunine");

而不是

Double fil2= res.getDouble("quninew");