首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >java.sql.SQLException: ORA-00604:递归SQL1级出错

java.sql.SQLException: ORA-00604:递归SQL1级出错
EN

Stack Overflow用户
提问于 2012-11-06 18:43:23
回答 1查看 27.9K关注 0票数 2

我得到了下面的SQL异常,我不知道这个异常的根本原因是什么?我还关闭了db连接和语句。

代码语言:javascript
运行
复制
java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-01000: maximum open cursors exceeded
ORA-00604: error occurred at recursive SQL level 1
ORA-01000: maximum open cursors exceeded
ORA-01000: maximum open cursors exceeded

以下是我的代码:

代码语言:javascript
运行
复制
 while(true)
 {

   Statement stmt2 = conn1.createStatement();
   ResultSet rs2 = null;

   int rec_count=0;
   rs2 = stmt2.executeQuery("select count(*) as cnt from   some_table");                                  
    while(rs2.next())
   {
     rec_count = rs2.getInt("cnt");
   }

   if(rec_count>0)
   {
     update_qry_b_trg1 = "update some_table set to_be_triggered=1,algo_status='D',dealer_id='HD001',price_trig_date=sysdate where buy_sell = 'SELL' and ordertype = 'BNLD' and to_be_triggered = 0 and algo_status = 'P' and Mod(group_ref_no,5)="+th_id;

   String final_qry = "BEGIN \n"+update_qry_b_trg1+";\n"+";\n END;";

   int rows = stmt1.executeUpdate(final_qry);
   stmt1.close();
   }

   rs2.close();
   stmt2.close();

   }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-26 01:13:22

无论stmt1在哪里初始化,最好在finally块中将其关闭。在您的示例中,您将在if条件下关闭它。如果条件没有通过,语句将保持打开状态,您将得到以下结果

代码语言:javascript
运行
复制
java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1

此外,您还在while循环中运行此语句,因此您需要确保关闭每个打开的语句。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13249297

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档