[常见FAQ] websphere6.1对ResultSet强制关闭的问题
aurora
2007-09-21
WebSphere6.1对ResultSet会产生强制的关闭,下面的这部分代码在WebLogic8.1下是没有问题的,但是我将它移植到了WebSphere6.1的环境下,
public static ArrayList getAllRoles(Connection conn) throws SQLException { PreparedStatement pstmt = null; ArrayList al = new ArrayList(); String sql = "select role_code,role_name,role_desc from " + RoleBean.TB_ROLE + " order by role_code"; try { pstmt = conn.prepareStatement(sql); ResultSet rs1 = pstmt.executeQuery(); while (rs1.next()) { RoleBean role = new RoleBean(rs1.getString("role_code"), rs1.getString("role_name"), rs1.getString("role_desc"), null); role.setPrivList(role.getPrivs(conn));//在这里调用了getPrives(conn)方法,当代码运行到这的时候报错,显示com.ibm.db2.jcc.b.SqlException: [ibm][db2][jcc][10120][10898] 操作无效:已关闭 result set,为什么会出现这个问题?请高手帮助分析一下。先谢谢了。 al.add(role); } rs1.close(); return al; } catch (SQLException e) { throw e; } finally { if (pstmt != null) { pstmt.close(); } } ----------------------- public ArrayList getPrivs(Connection conn) throws SQLException { PreparedStatement pstmt = null; String sql = "select r.menu_code,p.priv_name , p.tree_level from " + this.TB_ROLE_PRIV + " r," + this.SM_PRIV_TB + " p" + " where r.role_code='" + this.roleCode + "'" + " and r.menu_code = p.priv_no" + " order by menu_code, p.tree_level"; try { Statement stmt = conn.createStatement(); // ResultSet rs = pstmt.executeQuery(); ResultSet rs = stmt.executeQuery(sql); ArrayList al = new ArrayList(); while (rs.next()) { PrivBean priv = new PrivBean(rs.getString("menu_code"), rs.getString("priv_name"), rs.getInt("tree_level")); al.add(priv); } // rs.close(); return al; } catch (SQLException e) { throw e; } finally { if (pstmt != null) { pstmt.close(); } } |
|
aurora
2007-09-26
该问题解决了。
|
|
qtlkw
2010-07-11
你用db2吧?设置一下数据源的定制属性就可以, right?
|
|
dingdingfm
2010-07-13
楼主,问题出在哪儿,讲出来分享一下吧。thanks!
|
相关讨论
相关资源推荐
- 用C#代码操作WEB.config文件
- 运行时动态修改webconfig
- C#-动态改变Web.config的值
- Bochs-2.4.1 配置文件
- 爬虫:Ajax数据爬取
- action 向ajax传递错误讯息,关于jquery:Ajax Action调用抛出一个错误
- Ajax 常见问题解决(IE缓存问题,请求超时,网络异常,请求取消,请求重复迭代,JSON数据转化,跨域)
- js数组再倒数第二个添加元素_jquery如何定位倒数第二个元素,如一个div里有5个ul,那jquery如何才能锁定到倒数第二个ul...
- html div 层级,深入浅出CSS:Div(一)
- 如何修改Web.Config里面的值