首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 企业软件 > 行业软件 >

关于ORACLE游标的有关问题(ORA-01000 maximum open cursors exceeded)

2012-10-23 
关于ORACLE游标的问题(ORA-01000 maximum open cursors exceeded)?这几天准备项目上线前发现问题,ORA-0100

关于ORACLE游标的问题(ORA-01000 maximum open cursors exceeded)

?这几天准备项目上线前发现问题,ORA-01000 maximum open cursors exceeded 而且好几个功能出现类似问题

在网上也查了资料,都说是游标越界了 建议增大游标,后来架构师检查了下代码,原来是preparedStatement没有关闭,汗!

?

Session hibernateSession = (Session) Component.getInstance("hibernateSession");
??? ??? String hql = "select current_timestamp from dual";
??? ??? Connection conn = hibernateSession.connection();
??? ??? try {
??? ??? ??? PreparedStatement pstmt = conn.prepareStatement(hql);
??? ??? ??? ResultSet rs = pstmt.executeQuery();
??? ??? ??? if (rs.next()) {
??? ??? ??? ??? Timestamp time = rs.getTimestamp("current_timestamp");
??? ??? ??? ??? return time;
??? ??? ??? }
??? ??? } catch (SQLException e) {???
??? ??? }
??? ??? return new Timestamp(System.currentTimeMillis());

此方法没有关闭 pstmt 、rs、conn

?

使用了框架之后,此类问题很难发现,同时也是非常低级的问题?? 以后一定要注意,手动取得连接、创建PreparedStatement 获得ResultSet? 记得一定关闭资源!

?

?

?

?

?

?

?

?

热点排行