2

以下の SQL 例外が発生しましたが、この例外の根本的な原因がわかりません。また、db接続とステートメントも閉じています。

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

以下は私のコードです:

 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();

   }
4

1 に答える 1

1

stmt1 が初期化される場所はどこでも、finally ブロックで閉じることをお勧めします。あなたの場合、if条件で閉じています。条件が満たされない場合、ステートメントは開いたままになり、これを取得します

java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1

また、これはwhileループで実行されているため、開いているステートメントをすべて閉じる必要があります。

于 2013-04-25T17:13:22.030 に答える