【发布时间】:2019-01-14 04:04:37
【问题描述】:
我正在使用以下查询来提取选定的数据
String fetch_head = "select * from head_category where id = (?)";
但我不知道如何通过 ResultSet 拉行并同时使用 PreparedStatement 提供参数。
public ArrayList fetch_selected() {
ArrayList arrayList = new ArrayList();
try {
connectionFactory cf = new connectionFactory();
con = cf.getcon();
st = con.createStatement();
rs = st.executeQuery(fetch_head);
while (rs.next()) {
// it only fetches all
}
} catch (Exception e) {
e.printStackTrace();
}
return arrayList;
}
现在我应该把 PreparedStatement 放在哪里...?
【问题讨论】:
标签: jsp servlets jakarta-ee