删除表格选中项
public void delete(int row) {
String sql = "delete from mis where id=?";
try {
pstmt = (PreparedStatement) getConn().prepareStatement(sql,
ResultSet.CONCUR_READ_ONLY);
pstmt.setString(1, (String) model.getValueAt(row, 1));
pstmt.executeUpdate();
JOptionPane.showMessageDialog(null, "删除成功!");
} catch (
SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
JOptionPane.showMessageDialog(null, "删除失败!");
} finally {
close();
}
}
------解决方案--------------------(String) model.getValueAt(row, 1));改成model.getValueAt(row, 1).toString() 会不会好点
------解决方案--------------------
你debug下看看哪里没有值吧