如何将结果集打印到文本字段中?到目前为止,我只能打印一个而不是第二个。假设我在结果集中只有2个项目,并且我想将它们放入两个单独的文本字段中,到目前为止我有:
String Question = (jQuestion.getText());
String sql = "SELECT a.options FROM answers a, questions q WHERE q.question = '"+Question+"' AND a.question_id = q.question_id";
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
while (rs.next()) {
String option = rs.getString("options");
jAnswerA.setText(option);
}while (rs.next()) {
String optionB = rs.getString("options");
jAnswerB.setText(optionB);
}
答案 0 :(得分:0)
if (rs.next()) {
String option = rs.getString("options");
jAnswerA.setText(option);
};
if (rs.next()) {
String optionB = rs.getString("options");
jAnswerB.setText(optionB);
};