ORA-01000:超出最大打开游标的异常

时间:2018-11-17 19:50:04

标签: java oracle

在执行以下程序时,出现异常“ ORA-01000:超出最大打开游标数”。请帮助

public static void main(String[] args)    throws ClassNotFoundException, SQLException
  {
    PreparedStatement ps = null;
    Connection con = null;
    ResultSet rs = null;
    BufferedReader br = null;
    try
    {
        String line = null;
        while ((line = br.readLine()) != null)
        {

          if ((acctNumber != null) && (!acctNumber.trim().isEmpty()))
          {
            ps = con.prepareStatement("SELECT * FROM BANK WHERE ACCT_NBR = ?");
            ps.setString(1, acctNumber);
            rs = ps.executeQuery();

            if (!rs.next())
            {
              logger.info("Account not present in BANK table: " + acctNumber);
            }
            else {
                ps = con.prepareStatement("UPDATE BANK SET ------ WHERE ACCT_NBR = ?");
                ps.setString(1, acctNumber);
                ps.executeUpdate();

                ps = con.prepareStatement("INSERT INTO BANK_NEW_BRANCH ------- ");
                ps.setString(1, acctNumber);               
                ps.executeUpdate();            

            }
          }
          else
          {
            logger.info("Account Number is empty");
          }
        }
      }
      catch (SQLException e) {
        logger.error("SQL Exception occured while executing the query " + e.getMessage());
      }

      br.close();
      try
      {
        if ((rs != null) && (rs.isClosed())) {
          rs.close();
        }
        if ((ps != null) && (ps.isClosed())) {
          ps.close();
        }
        if ((con != null) && (con.isClosed()))
          con.close();
      }
      catch (Exception e) {
        logger.error("Exception occured while closing the connections, Exception details " + e.getMessage());
      }
    }
    catch (IOException e)
    {
      logger.error("Exception occured", e.getMessage());
    }
  }
}

0 个答案:

没有答案