为什么它会超出界限?我就是不明白为什么会超出范围。
for(int g=0;g<tblDependent.getRowCount();g++)
{
insertdep.execute("INSERT INTO EmployeeDependentTable Values('"+
txtEmpNumber.getText()+"','"+
tblDependent.getValueAt(g, 0)+"','"+
tblDependent.getValueAt(g, 3)+"','"+
tblDependent.getValueAt(g, 1)+"','"+
tblDependent.getValueAt(g, 4)+"','"+
tblDependent.getValueAt(g, 2)+"')");
}
发布于 2013-08-17 05:12:43
我想问题出在这部分
tblDependent.getValueAt(g, 4)+"','"+
假设列索引是从零开始的,则可能没有第5列。
发布于 2013-08-17 06:07:08
错误消息显示"Out of bound 4>=4“。
这意味着可能是tblDependent.getValueAt(g, 4)
造成了问题。
您可能只有4列,因此getValueAt(g, 4)
会引发OutOfBounds异常。
附注
请担心SQL注入。
https://stackoverflow.com/questions/18282146
复制相似问题