My last questions/problems are solved thank you for the advice. In which, I have another problem encountered says:
java.lang.ArrayIndexOutOfBoundsException:-1
My code in updating is when click from a jtable it will be shown in a textfield, my code:
> try{
> DefaultTableModel model= (DefaultTableModel)tbl_stud.getModel();
> model.fireTableDataChanged();
> int row=tbl_stud.getSelectedRow();
> String tbl_click=(tbl_stud.getModel().getValueAt(row, row).toString());
> String sql="Select * from students where id_num='"+tbl_click+"';";
> pst=conn.prepareStatement(sql);
> rs=pst.executeQuery(sql);
> if(rs.next()){
> String add1=rs.getString("id_num");
> up_idnum.setText(add1);
> String add2=rs.getString("fname");
> up_fname.setText(add2);
> String add3=rs.getString("mname");
> up_mname.setText(add3);
> String add4=rs.getString("lname");
> up_lname.setText(add4);
>
> String add8=rs.getString("username");
> up_username.setText(add8);
> String add9=rs.getString("password");
> up_pass.setText(add9);
> update_table();
> }
>
>
> }
> catch(Exception o){
> JOptionPane.showMessageDialog(null, o);
>
> }
> }
but i always get that error, how can i prevent it? thank you.
String tbl_click=(tbl_stud.getModel().getValueAt(row, row).toString());
在Model中,您需要获取ID为num的选定行和列索引的值。
String tbl_click=(tbl_stud.getModel().getValueAt(row, columnNo).toString());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.