(一定赚了分才采纳) java.sql.SQLException:关闭的 Resultset:nextString sql="select * from t_student";\x05\x05List list = jdbcTemplate.query(sql,new RowMapper() {\x05\x05\x05public Object mapRow(ResultSet rs,int arg1) throws SQLException
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/04 13:51:37
![(一定赚了分才采纳) java.sql.SQLException:关闭的 Resultset:nextString sql=](/uploads/image/z/14029997-5-7.jpg?t=%EF%BC%88%E4%B8%80%E5%AE%9A%E8%B5%9A%E4%BA%86%E5%88%86%E6%89%8D%E9%87%87%E7%BA%B3%EF%BC%89+java.sql.SQLException%3A%E5%85%B3%E9%97%AD%E7%9A%84+Resultset%3AnextString+sql%3D%22select+%2A+from+t_student%22%3B%5Cx05%5Cx05List+list+%3D+jdbcTemplate.query%28sql%2Cnew+RowMapper%28%29+%7B%5Cx05%5Cx05%5Cx05public+Object+mapRow%28ResultSet+rs%2Cint+arg1%29+throws+SQLException)
(一定赚了分才采纳) java.sql.SQLException:关闭的 Resultset:nextString sql="select * from t_student";\x05\x05List list = jdbcTemplate.query(sql,new RowMapper() {\x05\x05\x05public Object mapRow(ResultSet rs,int arg1) throws SQLException
(一定赚了分才采纳) 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()
(一定赚了分才采纳) java.sql.SQLException:关闭的 Resultset:nextString sql="select * from t_student";\x05\x05List list = jdbcTemplate.query(sql,new RowMapper() {\x05\x05\x05public Object mapRow(ResultSet rs,int arg1) throws SQLException
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的意思就是每行