有兩個可能
1、rs ,state和conn沒有關閉
rs.close(); state.close(); conn.close();
if(rs!=null) rs.close; if(state!=null) state.close; if(conn!=null) conn.close;
---
流程
import java.sql.Connection;
Connection conn = null;
try {
conn = getConnection();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
} finally {
closeConnection(conn); // 關閉連接
}
2、執行的數據庫查詢沒有查詢到任何結果,卻調用了rs.next() 或者,游標到了查詢出來的最后一條記錄,又調用了rs.next()則,會找不到next條記錄
String swglm_hou = rs_select2.getString(1);
我是這一行報錯,而且是執行到循環的最后一次循環才報的錯