(一定赚了分才采纳) 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的意思就是每行
我来回答修改/报错/举报内容!
猜你喜欢
- 48÷12.5怎么简算
- 歌词里有ruai ruai dou ruai mi 而且是一个男人和一个小女孩唱的歌歌名叫啥啊
- 写一段话,下面给出的短语至少运用3个 A、学而时习之 B、有朋自远方来 C、温故而知新 D、学而不思则罔
- 用最的一句话来分别概括名著
- 这句话错哪里了? 
- 张骞是如何评价匈奴人的
- 3道英语选择题.我加10悬赏分.
- 已知:p为等边△ABC内任意一点,PD⊥AB于D,PE⊥AC于E,PB⊥BC于F.求证:PD+PE+PF是定值
- 请看下这句话是否正确 Going to KFC eating fast food is a good way to sa
- my teacher often helps me with my english的同义句?
- Exception in thread "main" java.sql.SQLException:用尽的 Results
- java.sql.SQLException:Column count doesn't match value count