+ -
当前位置:首页 → 问答吧 → 求助!!PreparedStatement的问题

求助!!PreparedStatement的问题

时间:2011-12-23

来源:互联网

大家帮个忙哈 我从数据库里边把想要查询的东西 读到jtable里边了 然后 修改jtable里边的内容 想要更新回数据库
但是 更新的结果是 原来的内容都跟jtable里边最后一行的一样了 这是为什么 帮忙解决下  
sql语句
String sql = "update train set Station = ?, Day = ?, A_Time = ?, D_Time = ?, Distance = ?, P1 = ?, P2 = ?, P3 = ?, P4 = ? where ID = ? ";
循环代码
for (int i = 0; i < table.getRowCount(); i++) {
for (int j = 1; j < table.getColumnCount(); j++) {
s = (String) table.getValueAt(i, j);
prea.setString(j, s);
}
prea.setString(10, string);

}
prea.executeUpdate();

作者: hnndyangzidian   发布时间: 2011-12-23

你的这个循环到最好只会执行最后一次的更新呀,试试executeBatch吧

作者: zhj92lxs   发布时间: 2011-12-23

热门下载

更多