open_cursors参数用于指定数据库中能够同时打开的游标数量,每条查询语句都需要打开一个游标的.

解决方案 »

  1.   

    是在批量操作造成的,但是我每次用都关了,并且我设的数据是30000啊。还有我在v$open_cursor中看到有我用过的几千个游标,我程序都管了他怎么还存在啊,请教一下在v$open_cursor中存在的是什么情况的游标。
      

  2.   

    游标最大数是一个连接的最大数,你可以每次用时都建一次连接(虽然这样很浪费,但我是这样解决的,速度没有问题),用完CLOSE. 这样就不会出现超出游标最大数的问题.
    还有不要用RS了,将它转为VECTOR.
      public static Vector rsToVector (String sqlQuery, Connection db) {
        Vector vRS = new Vector();
        CallableStatement csmt = null;
        Connection conn = null;    try {
          conn = db.getConnection();
          csmt = conn.prepareCall("{?=call pkg_wzbm_manage.getSearchResult(?)}",
                                  ResultSet.TYPE_SCROLL_INSENSITIVE,
                                  ResultSet.CONCUR_UPDATABLE);
          csmt.registerOutParameter(1, oracle.jdbc.OracleTypes.CURSOR);
          csmt.setString(2, sqlQuery);
          csmt.executeQuery();      ResultSet db_rset = (ResultSet) csmt.getObject(1);      //ResultSet db_rset = db.executeQuery(sqlQuery);
          //Get the ResultSetMetaData. This will be used for the column headings
          ResultSetMetaData rsmd = db_rset.getMetaData();      //Get the number of columns in the result set
          int numCols = rsmd.getColumnCount();
          boolean more = db_rset.next();
          while (more) {
            Vector columns = new Vector();
            for (int i = 1; i <= numCols; i++) {
              String tempStr = db_rset.getString(i);
              if (tempStr == null)
                tempStr = "";
              tempStr = tempStr.trim();
              columns.addElement(tempStr);
            }        vRS.addElement(columns);
            more = db_rset.next();
          }
          db_rset.close();
        }
        catch (Exception ex) {
          ex.printStackTrace();
        }
        finally {
          try {
            csmt.close();
          }
          catch (Exception ex) {      }
        }
        return vRS;
      }