返回结果集问题,菜鸟求解
调用一下函数,但是会显示结果集已关闭,去掉this.closeAll(conn, pstmt, null);后可以用,但是没关掉Connection和PreparedStatement,求大神一个好的方法处理结果集的返回。
public ResultSet SelectSQL(String sql)
{
conn=this.getConnection();
ResultSet rs=null;
PreparedStatement pstmt=null;
try {
pstmt=conn.prepareStatement(sql);
rs=pstmt.executeQuery();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
this.closeAll(conn, pstmt, null);
}
return rs;
}