当前光标位置(JBDC)的无效操作

时间:2017-03-19 11:12:10

标签: java jdbc

private void updateActionPerformed(java.awt.event.ActionEvent evt) {                                       

     String id_col=studid.getText();
     String last_name=lastname.getText();
     String first_name=firstname.getText();
     String course=cr.getText();
     String school=sc.getText();
     String GPA=gpa.getText();
     String SCHOLARSHIP=scholar.getText();

     int newID = Integer.parseInt(id_col);
     double GPa=Double.parseDouble(GPA);
     int scholars=Integer.parseInt(SCHOLARSHIP);

          try{

         rs.updateRow();
         rs.updateInt("STUDENT_ID", newID);
         rs.updateString("LAST_NAME", last_name);
         rs.updateString("FIRST_NAME", first_name);
         rs.updateString("COURSE", course);
         rs.updateString("SCHOOL", school);
         rs.updateDouble("GPA", GPa);
         rs.updateInt("SCHOLARSHIP", scholars);




         JOptionPane.showMessageDialog(STUDENSCHOLARSHIP.this,"UPDATED");

     }  
     catch(SQLException err){
         System.out.println(err.getMessage());

     }

  fetch();
    }   

我尝试if(rs.next()){}但它不会工作。帮我吧.. :(

1 个答案:

答案 0 :(得分:1)

更新列后必须调用

rs.updateRow ()