结果集将显示在多个文本字段中



如何将结果集打印到文本字段中?到目前为止,我只能打印一个,不能打印第二个。假设我在结果集中只有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);
        }
if (rs.next()) {
     String option = rs.getString("options");
     jAnswerA.setText(option);
};
if (rs.next()) {
     String optionB = rs.getString("options");
     jAnswerB.setText(optionB);
};

相关内容

  • 没有找到相关文章

最新更新