[英]I am getting indexOutOfBoundsException whenever I try to get the value on my table and use it on `setString`
I cant get the data on my table when using setString()
method it says that indexOutOfBoundsException使用
setString()
方法时,我无法获取表上的数据,它说 indexOutOfBoundsException
String upd = "update sinfo set sname = ?, course = ?, section = ?, dob = ?, address = ? where sid = ?";
String sc = course.getSelectedItem().toString();
TableModel model = sTable.getModel();
int i = sTable.getSelectedRow();
pst = conn.prepareStatement(upd);
pst.setString(1, sn.getText());
pst.setString(2, sc);
pst.setString(3, ss.getText());
pst.setString(4, db.getText());
pst.setString(5, ad.getText());
pst.setString(6, model.getValueAt(i,0).toString()); //I get the error here saying indexOutOfBoundsException: -1
pst.executeUpdate();
I already fixed it, camickr is right.我已经修好了,camickr 是对的。 Whenever I select a row on a table, the selected row will reset.
每当我在表格上选择一行时,选定的行将重置。 And that is the cause of the error.
这就是错误的原因。 Thank you and sorry because im new to programming and using this site😅
谢谢你,对不起,因为我是编程和使用这个网站的新手😅
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.