【发布时间】:2020-04-07 20:19:13
【问题描述】:
使用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”变量上,因为您没有选定的行?
-
我已经选择了一行,然后当我尝试执行该功能时,我得到 pst.setString(6, model.getValueAt(i,0).toString()); 上的错误;跨度>