(一定赚了分才采纳) 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/04/20 21:29:21
(一定赚了分才采纳) java.sql.SQLException:关闭的 Resultset:nextString sql=

(一定赚了分才采纳) 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的意思就是每行