在当前游标位置的无效操作(Java DB)



所以我试图做一个保存按钮来更新数据库内的列根据什么输入到相应的文本字段,但我一直得到这个错误"在当前光标位置无效的操作"。我不知道出了什么问题,因为其他的都在工作。有人能帮忙吗?提前感谢!

private void btn_saveActionPerformed(java.awt.event.ActionEvent evt) {                                         
  i = Integer.parseInt(txt_userid.getText( ));
  s = txt_pass.getText( );
  n = txt_name.getText( );
  birthdate = txt_bdate.getText();
  contactno = Integer.parseInt(txt_contact.getText());
  age = Integer.parseInt(txt_age.getText());
  email = txt_email.getText();
  address = txt_address.getText();
  gender = txt_gender.getText();
  adult = Integer.parseInt(txt_adult.getText());
  child = Integer.parseInt(txt_child.getText());
  senior = Integer.parseInt(txt_senior.getText());
  charge = Integer.parseInt(txt_charge.getText());
  travelclass = txt_travelclass.getText();
  luggage = txt_luggage.getText();
  flightID = txt_flightid.getText();
  departdate = txt_depardate.getText();
  departtime = txt_departime.getText();
  destination = txt_destination.getText();
  arrivdate = txt_arrivdate.getText();
  arrivtime = txt_arrivtime.getText();
  try{
      rs.updateInt("USERID",i);
      rs.updateString("PASSWORD",s);
      rs.updateString("USERNAME",n);
      rs.updateInt("AGE",age);
      rs.updateString("GENDER",gender);
      rs.updateString("BIRTHDATE",birthdate);
      rs.updateString("EMAIL",email);
      rs.updateInt("CONTACTNO",contactno);
      rs.updateString("ADDRESS",address);
      rs.updateString("FLIGHTID", flightID);
      rs.updateString("DEPARDATE", departdate);
      rs.updateString("DEPARTIME", departtime);
      rs.updateString("DESTINATION", destination);
      rs.updateString("TRAVELCLASS", travelclass);
      rs.updateString("LUGGAGE", luggage);
      rs.updateInt("TOTALPAY", charge);
      rs.updateInt("ADDPASSENGERSSENIOR", senior);
      rs.updateInt("ADDPASSENGERSADULT", adult);
      rs.updateInt("ADDPASSENGERSCHILD", child);
      rs.updateString("ARRIVALDATE", arrivdate);
      rs.updateString("ARRIVALTIME", arrivtime);
      rs.updateRow( );
      Refresh_RS_STMT();
      ShowAll();
      JOptionPane.showMessageDialog(AdminWindow.this,
              "Record has been saved!");
  }catch(SQLException err){
      System.out.println(err.getMessage() );
  }
}                                        

在使用ResultSet对象之前尝试调用rs.next()。事实上,一个新的ResultSet对象内部有一个指针指向-1(默认情况下没有任何结果),当您第一次调用next()方法时,它将指向第一行,如果存在,并返回true,否则将返回false。每次调用它时,它都会尝试指向下一行,以此类推。

相关内容

  • 没有找到相关文章

最新更新