(一定赚了分才采纳) java.sql.SQLException:关闭的 Resultset:next

首页/题库/176℃/2024-05-19 04:10:06

(一定赚了分才采纳) java.sql.SQLException:关闭的 Resultset:next

String sql="select * from t_student";

\x05\x05List list = jdbcTemplate.query(sql,new RowMapper() {

\x05\x05\x05public Object mapRow(ResultSet rs,int arg1) throws SQLException {

\x05\x05\x05\x05List list = new ArrayList();

\x05\x05\x05\x05try {

\x05\x05\x05\x05\x05

\x05\x05\x05\x05\x05\x05while (rs.next()) {

\x05\x05\x05\x05\x05\x05.\x05

}

而且异常指向的是这一行:

List list = jdbcTemplate.query(sql,new RowMapper()

优质解答:

while (rs.next()) {

\x05\x05\x05\x05\x05\x05.\x05

}

这个不需要这么写,直接写

Students st = new Students();

st.setName(rs.getString(1));

list.add(st);

因为是每行结果所以你再rs.next()就报错了,已经被关闭了,你看,mapRow的意思就是每行

我来回答修改/报错/举报内容!

猜你喜欢

一个神奇的在线题库网,分享各类考试题库、题目资料与资料答案、在线搜题与练习等!
本网站部分内容、图文来自于网络,如有侵犯您的合法权益,请及时与我们联系,我们将第一时间安排核实及删除!
Copyright © 2021-2024 315题库 All Rights Reserved