高分求助 关于Iterator的问题
public InputStream getSqlImage(String sql,String tier) {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
InputStream in = null;
try {
conn = getConnection();
if(conn==null){
return null;
}
pstmt = conn.prepareStatement(sql);
if(pstmt!=null){
rs = pstmt.executeQuery();
}
if(rs!=null){
if(rs.next()){
in = rs.getBinaryStream(tier);
}
}
}catch (Exception e) { } finally {
rs.close();
pstmt.close();
conn.close();
}
这么写返回的InputStream 是没有值的,因为rs、pstmt、conn都已经关掉了
我想在方法里面把rs、pstmt、conn都关掉,然后返回的对象还有值
比如说利用Iterator 可是具体怎么写,请高手指点一下。。或者用别的方法写出来也行