我无法在我的数据库中插入数据..这是我的代码看起来像..
rs = stat.executeQuery("Select * from students;");
while (rs.next()) {
idNum = rs.getString("idNum");
stat.executeUpdate(
"INSERT INTO record VALUES (null,'" + idNum + "','" + descript +
"'," + value + ",'" + user.getText() + "','" + timeStamp + "')"
);
}//while
如您所见,我想为每个学生插入一个数据rs = stat.executeQuery("Select * from students;");
并获取他们所有的学生编号idNum = rs.getString("idNum");
,这就是学生表中的内容:
idNum..............Name
11000001.........Leonardo
11000002.........David
11000003.........Robert
11000004.........Anna
11000005.........May
现在,当我得到他们所有的 idNum 时,我希望将它们插入到如下所示的表记录中:
idNum.........descript.........amount........blablablabla
11000001.......Fee...............30
11000002.......Fee...............30
11000003.......Fee...............30
11000004.......Fee...............30
11000005.......Fee...............30
问题是只有第一个 idNum 被插入到表记录中,如下所示:
idNum.........descript.........amount........blablablabla
11000001.......Fee...............30