Viewer leaving open cursors in Oracle

We are using the JRC to display reports in our software. We are running jboss-4.2.0 as our application server. The backend could be either SQL Server or Oracle. For Oracle we are using the oracle.jdbc.driver.OracleDriver driver. The reports are set up using a JDBC (JNDI) connection. Generally we have it working ok but in Oracle the JRC is leaving open cursors leading to  ORA-01000: MAXIMUM OPEN CURSORS EXCEEDED. I have found that a new cursor is opened when the data source is changed in the following code snippet
Iterator tableIT = tableNames.iterator();
while (tableIT.hasNext()) {
  ITable oldTable = (ITable)tableIT.next();
  ITable table = (ITable) ((IClone)oldTable).clone(true);
  table.setQualifiedName(table.getName());
  clientDoc.getDatabaseController().setTableLocation(oldTable, table);
When we hit the last line in this loop, a new cursor is opened in Oracle so if a report has 10 tables, I get 10 cursors opened. I know that I need to close the cursors somehow but nothing I do seems to make a difference. After my processHttpRequest call to the viewer I added:
crystalReportPageViewer.getReportSource().dispose();
clientDoc.getReportSource().dispose();
The code definately executes but the the number of open cursors in Oracle does not change. I am at a loss.

A couple more things to think about then.
1.  When you go through your loop to set your table location, you are using the clone method to create a new table and then pass that table to the report.  Cloning tables is no longer necessary with the JRC.  We do know that a fix was provided for the JRC SDK, however this fix would probably not have been applied to the clone method since it has been deprecated.
I have attached a sample that shows the new methodology for setting table location; very similar, just not using clone anymore.
2.  When you want to destroy any connections that the ReportClientDocument has made, you will need to call .close() on this object.  This can be done in conjunction with the viewer.dispose().  One thing to note is that if you call the .close() method, it will need to be done as the user is closing the browser, or you will not have access to your report object when you have it open in the HTML Viewer.

Similar Messages

  • Maximum Open Cursors Exceeded - Oracle & Java

    I am using NetBeans ( Forte 5) for developing an application with Oracle Database. My application makes use of executeUpdate, executeQuery statements inorder to access Database.
    After few insertions and deletions of data through the host language( Java), my application stops working. It gives out the error.
    java.sql.SQLException: ORA-01000: maximum open cursors exceeded[/b
    Is this the problem with Forte or Oracle. I am using Oracle in a network in which i have got a tablespace in the Database server.
    How to tackle this problem.

    I am using 3 methods preparedStatements
    1. execute - returns boolean
    2. executeQuery - returns ResultSet
    3. executeUpdate - returns int
    I am closing the ResultSet object returned by executeQuery using
    close() method.
    Is this the correct way to close the open cursor.
    I access the table attributes using a rs.getString(colNum) and
    rs.getInt(colNum)
    Even then i am getting the maximum open cursors exceeded message.
    Will Oracle open a cursor for execute and executeUpdate which is not returning a ResultSet object .
    If Oracle opens a cursor for these two methods, how should i close the open cursor.

  • Open cursor query - oracle 10g

    Could anyone tell me which is the right query for fetching open cursor:
    1.
    select max(a.value) as highest_open_cur,s.sid, s.username, oc.sql_text, s.logon_time, s.status, s.machine
    from v$sesstat a, v$statname b, v$parameter p, v$session s, v$open_cursor oc
    where a.statistic# = b.statistic#
    and b.name = 'opened cursors current'
    and p.name= 'open_cursors'
    and username in ('USER_ID')
    and s.sid = a.sid
    -- and s.status <> 'KILLED'
    and oc.sid = s.sid
    group by s.sid,s.username, oc.sql_text, s.logon_time, s.status, s.machine
    order by s.logon_time desc
    2.
    SELECT user_name,sid,sql_text,count(1) total,sysdate snap_time
    FROM v$open_cursor
    WHERE user_name IN ('USER_ID')
    GROUP BY user_name,sid,sql_text
    HAVING count(1)>0;
    The issue is inthe secind query we have had hardly any open cursors and from the first query we are getting quiet a lot.
    Would like someone to explain me the the interpretation of both the queries.
    Does Oracle 10g has a different interpretation of these tables.
    How should we be reading the open cursors? and
    Does anyone feel there is a better way to check for open cursors ?

    ...etc...
    How should we be reading the open cursors? and
    Does anyone feel there is a better way to check for
    open cursors ?Forget cursors, if your purpose is to do some kind of research for performance tuning, just generate either the Enterprise Manager ASH or ADDM reports.

  • Maximum Open Cursors Exceeded - Oracle 9 & Java Web Server 6.1

    We are facing this problem - maximum open cursors exceeded after migrating our application to Sun Java System Web Server 6.1
    We were not facing this problem with our earlier web server
    Can anybody let us know - is there any setting we need to do to avoid this.
    The current setting for this attribute in the database is quite huge - close to 2000
    One of the "webservd" sessions, (web server user) exceeded this value

    See my reply in your duplicated post:
    http://swforum.sun.com/jive/thread.jspa?threadID=57989&messageID=220483#220483

  • Cursor.count( ) leaves open cursors?

    Hi, I am seeing a weird scenario inside a JUnit test -- they symptom is if I call cursor.count( ); in the code, and then close everything properly (I think), when I call close( ) on the environment, it throws a DB exception and claims there are cursors still open. If I comment out the call to cursor.count( ); this exception goes away.
    Example inside JUnit test:
    EntityIndex<Long, FaceEdge> subIndex = da.faceEdgeByEdgeId.subIndex(12L);
    assertFalse(cursor.count( ) == 0);
    try {
       for (FaceEdge fe : cursor) {
           assertTrue(fe.getEdgeId( ) == 12L);
       } finally {
           cursor.close( );
    }The JUnit tearDown looks like this:
    super.tearDown( );
    myDbEnv.close( );...and myDbEnv.close( ) looks like this:
    if (store != null) {
       try {
           store.close( );
       } catch(DatabaseException dbe) {
          etc.
    if(myEnv != null) {
       try {
           myEnv.close( );
       } catch(DatabaseException dbe) {
          // this gets caught and says there are cursors still open
    }The comment above is where the exception is caught. I use no other cursors anywhere, and if I comment out the line:
    assertFalse(cursors.count( ) == 0);..in the JUnit test, the exception goes away.

    Hello,
    EntityCursor<FaceEdge> cursor = subIndex.entities();
    assertFalse(cursor.count( ) == 0);I think the problem is that you're calling EntityCursor.count for an uninitalized cursor. The cursor must be advanced to the first entity before calling count() is allowed. In this situation a DatabaseException will be thrown with an "uninitialized cursor" message.
    Probably what is happening in your JUnit test is that the exception is thrown but your tearDown method still executes, or perhaps you have a finally block, and you're trying to close the EntityStore or the Environment. If you try to close the store or the environment with cursors left open, you'll get an exception telling you to close the cursors. Because of this second exception, you don't see the first exception about the cursor being uninitialized.
    I see this problem a lot in my own JUnit tests. :-) What I do is, in the tearDown method I put the calls to close the store and the environnment in a try/catch block. If an exception occurs, I print it, but I don't rethrow it. This allows the original exception (the one thrown by EntityCursor.count in your case) to be reported by JUnit. For example:
    public void tearDown() {
        if (store != null) {
            try {
                store.close();
            } catch (Throwable e) {
                System.out.println("During tearDown: " + e);
            store = null;
        if (env != null) {
            try {
                env.close();
            } catch (Throwable e) {
                System.out.println("During tearDown: " + e);
            env = null;
    }Mark

  • Oracle and "Maximum open cursors exceeded"

    Hi,
    I am using Weblogic 7.0sp2 with Oracle 9.2.0. Since we are using manual JTA
    transactions and the 9.2 drivers are buggy in that respect, we are using the
    9.0.1 thin drivers delivered with weblogic.
    The problem I have is that after a while, we get the now classic "Maximum open
    cursors exceeded" error on connections from our connection pool (used through
    a
    TX datasource). I have of course checked all our JDBC code and it is fine. We
    do not leave any statement/connection open. In fact, I am certain that the
    problem is not caused by our applicative code.
    The reason I am so positive is that the numbers of open (cached) cursors is
    growing, even though there is no activity on our application (I mean no
    activity at all). The number of cursors is regurlarly increasing by one
    every 5 minutes until it reaches the maximum allowed for a session.
    I have listed the statements corresponding to the opened cursors (they
    do not belong to our code, as you might have guessed):
    SELECT sysdate, user from dual
    select longdbcs from javasnm$ where short = :1
    select longname from javasnm$ where short = :1
    As you can see, there are only three different statements. You can get
    the statements from the system view v$open_cursor for a given session
    but it will only give one row per different statement. If you want to know
    the # of opened cursors in your cursor, use v$sesstat with statistic# = 3
    (opened cursor current).
    I suspect something is wrong in the connection testing done by weblogic
    for the pool (I have activated test on reserved connections and test table
    name is "dual") that leaves a resultset/statement behind. What is weird
    though is that the refresh period is still 0 (not 5 minutes as you would
    expect from the cursor growth rate...).
    I would not say that it is an Oracle bug (as stated in some BEA FAQ I read)
    since our application JDBC code does not exhibit the same problem. The
    problem appeared with recent version of WebLogic for which the session
    cursor cache is enabled, I suppose for performance reasons - this
    is set by isssuing "ALTER SESSION SET SESSION_CACHED_CURSORS = ...".
    Talking about this, does anybody know to which value WebLogic sets this
    parameter when intializing the connection (this is neither
    documented/configurable)?
    Up to now, I have come up with possibly two workarounds, neither of which
    is satisfying:
    - resetting the pool from time to time
    - issuing "ALTER SESSION SET SESSION_CACHED_CURSORS = 0" when I get a
    connection from the pool. I have not tested this one personally (read
    in a newsgroup that someone else did successfully) but it is supposed
    to reset the cursor cache that is causing the trouble.
    Any help will be greatly appreciated,
    Regards,
    Thierry.

    Thierry Rouget wrote:
    Hi,
    I am using Weblogic 7.0sp2 with Oracle 9.2.0. Since we are using manual JTA
    transactions and the 9.2 drivers are buggy in that respect, we are using the
    9.0.1 thin drivers delivered with weblogic.
    The problem I have is that after a while, we get the now classic "Maximum open
    cursors exceeded" error on connections from our connection pool (used through
    a
    TX datasource). I have of course checked all our JDBC code and it is fine. We
    do not leave any statement/connection open. In fact, I am certain that the
    problem is not caused by our applicative code.
    The reason I am so positive is that the numbers of open (cached) cursors is
    growing, even though there is no activity on our application (I mean no
    activity at all). The number of cursors is regurlarly increasing by one
    every 5 minutes until it reaches the maximum allowed for a session.
    I have listed the statements corresponding to the opened cursors (they
    do not belong to our code, as you might have guessed):
    SELECT sysdate, user from dual
    select longdbcs from javasnm$ where short = :1
    select longname from javasnm$ where short = :1
    As you can see, there are only three different statements. You can get
    the statements from the system view v$open_cursor for a given session
    but it will only give one row per different statement. If you want to know
    the # of opened cursors in your cursor, use v$sesstat with statistic# = 3
    (opened cursor current).
    I suspect something is wrong in the connection testing done by weblogic
    for the pool (I have activated test on reserved connections and test table
    name is "dual") that leaves a resultset/statement behind. What is weird
    though is that the refresh period is still 0 (not 5 minutes as you would
    expect from the cursor growth rate...).
    I would not say that it is an Oracle bug (as stated in some BEA FAQ I read)
    since our application JDBC code does not exhibit the same problem. The
    problem appeared with recent version of WebLogic for which the session
    cursor cache is enabled, I suppose for performance reasons - this
    is set by isssuing "ALTER SESSION SET SESSION_CACHED_CURSORS = ...".
    Talking about this, does anybody know to which value WebLogic sets this
    parameter when intializing the connection (this is neither
    documented/configurable)?
    Up to now, I have come up with possibly two workarounds, neither of which
    is satisfying:
    - resetting the pool from time to time
    - issuing "ALTER SESSION SET SESSION_CACHED_CURSORS = 0" when I get a
    connection from the pool. I have not tested this one personally (read
    in a newsgroup that someone else did successfully) but it is supposed
    to reset the cursor cache that is causing the trouble.
    Any help will be greatly appreciated,
    Regards,
    Thierry.Hi. We don't make those queries either. I suspect they are internal to the
    oracle driver. One thing you can try is to set the size of the pool's
    statement cache to zero. Oracle will retain cursors for every statement we
    cache. The alternative is also to tell the DBMS to allow a given session
    more cursors.
    Joe

  • Maximum open cursors exceeded from Oracle XA Connection pool

    I am on WLS 6.1 sp2.
    When i leave the server up overnight unaccessed and come back and see in the morning,
    I see the following stacktrace on the server console.
    I dont think its causing any harm, but is there anyway to prevent this from occuring?
    java.sql.SQLException: ORA-01000: maximum open cursors exceeded
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
    at oracle.jdbc.ttc7.Oopen.receive(Oopen.java:118)
    at oracle.jdbc.ttc7.TTC7Protocol.open(TTC7Protocol.java:466)
    at oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:413)
    at oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:432)
    at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:182)
    at oracle.jdbc.driver.OracleCallableStatement.<init>(OracleCallableStatement.java:102)
    at oracle.jdbc.driver.OracleCallableStatement.<init>(OracleCallableStatement.java:86)
    at oracle.jdbc.driver.OracleConnection.privatePrepareCall(OracleConnection.java:736)
    at oracle.jdbc.driver.OracleConnection.prepareCall(OracleConnection.java:622)
    at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:163)
    at weblogic.jdbc.jta.VendorXAResource.start(VendorXAResource.java:41)
    at weblogic.transaction.internal.ServerResourceInfo.start(ServerResourceInfo.java:1032)
    at weblogic.transaction.internal.ServerResourceInfo.xaStart(ServerResourceInfo.java:975)
    at weblogic.transaction.internal.ServerResourceInfo.enlist(ServerResourceInfo.java:234)
    at weblogic.transaction.internal.ServerTransactionImpl.enlistResource(ServerTransactionImpl.java:374)
    at weblogic.jdbc.common.internal.ConnectionEnv.test(ConnectionEnv.java:937)
    at weblogic.common.internal.ResourceAllocator.reserve(ResourceAllocator.java:465)
    at weblogic.common.internal.ResourceAllocator.reserveUnused(ResourceAllocator.java:376)
    at weblogic.common.internal.ResourceAllocator.trigger(ResourceAllocator.java:1103)
    at weblogic.time.common.internal.ScheduledTrigger.executeLocally(ScheduledTrigger.java:238)
    at weblogic.time.common.internal.ScheduledTrigger.execute(ScheduledTrigger.java:229)
    at weblogic.time.server.ScheduledTrigger.execute(ScheduledTrigger.java:65)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)

    Hi. I think this is an oracle driver problem, in all likelihood.
    We test a connection with:
    Statement stmt = c.createStatement();
    stmt.execute(sql);
    Where the string sql is "select count(*) from DUAL" if you named your test table as 'DUAL'.
    We obtain no result set, so the driver shouldn't be accruing cursors...
    Can you upgrade to the latest oracle driver?
    Can you upgrade to the latest version of 6.1?
    Jeeva wrote:
    I am on WLS 6.1 sp2.
    When i leave the server up overnight unaccessed and come back and see in the morning,
    I see the following stacktrace on the server console.
    I dont think its causing any harm, but is there anyway to prevent this from occuring?
    java.sql.SQLException: ORA-01000: maximum open cursors exceeded
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
    at oracle.jdbc.ttc7.Oopen.receive(Oopen.java:118)
    at oracle.jdbc.ttc7.TTC7Protocol.open(TTC7Protocol.java:466)
    at oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:413)
    at oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:432)
    at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:182)
    at oracle.jdbc.driver.OracleCallableStatement.<init>(OracleCallableStatement.java:102)
    at oracle.jdbc.driver.OracleCallableStatement.<init>(OracleCallableStatement.java:86)
    at oracle.jdbc.driver.OracleConnection.privatePrepareCall(OracleConnection.java:736)
    at oracle.jdbc.driver.OracleConnection.prepareCall(OracleConnection.java:622)
    at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:163)
    at weblogic.jdbc.jta.VendorXAResource.start(VendorXAResource.java:41)
    at weblogic.transaction.internal.ServerResourceInfo.start(ServerResourceInfo.java:1032)
    at weblogic.transaction.internal.ServerResourceInfo.xaStart(ServerResourceInfo.java:975)
    at weblogic.transaction.internal.ServerResourceInfo.enlist(ServerResourceInfo.java:234)
    at weblogic.transaction.internal.ServerTransactionImpl.enlistResource(ServerTransactionImpl.java:374)
    at weblogic.jdbc.common.internal.ConnectionEnv.test(ConnectionEnv.java:937)
    at weblogic.common.internal.ResourceAllocator.reserve(ResourceAllocator.java:465)
    at weblogic.common.internal.ResourceAllocator.reserveUnused(ResourceAllocator.java:376)
    at weblogic.common.internal.ResourceAllocator.trigger(ResourceAllocator.java:1103)
    at weblogic.time.common.internal.ScheduledTrigger.executeLocally(ScheduledTrigger.java:238)
    at weblogic.time.common.internal.ScheduledTrigger.execute(ScheduledTrigger.java:229)
    at weblogic.time.server.ScheduledTrigger.execute(ScheduledTrigger.java:65)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)

  • Problem in  Oracle EM (Database Limits - Current Open Cursors)

    Hi everyone,
    I have a problem in Oracle Enterprise Manager in All Metrics.
    When I select in All Metrics e.g. Health Check > Maintenance it work's fine and I see a chart.
    If I select in All Metrics > Database Limits > Current Open Cursors Count I got following error:
    Error
    oracle.sysman.dbTarget.db.emSDKOverride.page.mtrx.GetDataException: ORA-06550: Zeile 79, Spalte 16: PL/SQL: ORA-00942: Tabelle oder View nicht vorhanden ORA-06550: Zeile 51, Spalte 7: PL/SQL: SQL Statement ignored
    What's the problem?
    In this database instance i drop these users (schemas): dbuser, mddata, ordplugins, ordsys, si_informtn_schema!!
    Can this lack of user to cause an error?
    Oracle Enterprise Manager Database Control 10.2.0.0
    Database instance: myDB > All Metrics > Database Limits > Current Open Cursors Count
    Thanks.
    Mark

    Hello Mark,
    personally I don;t think it is a good idea to drop schema's from the database that have been installed as part of the activation of a certain Database Option. If you don't want the option, then don't instal it.
    For a complete description of the schema's you are refering to, check: http://download.oracle.com/docs/cd/E11882_01/server.112/e10575/tdpsg_user_accounts.htm#BABGIBBA
    Regards
    Rob
    http://oemgc wordpress.com

  • Open cursors problem- j2ee + oracle 10g

    Hi,
    I am using EJB on sunOne application server 8.1., Oracle 10g DB.
    EJB container connects to Oracle DB through a set of connection pools.
    BMP for all entity beans.
    I have about 160 PL/SQL functions that make up the business logic of the online application. everytime the application runs, I get an increasing number of open cursors, including some of the ones that are explicitly closed within PL/SQL (inspection with sys.v_$open_cursor).
    I made sure all CallableStatements, PreparedStatements, RecordSets within the beans are closed and set to NULL. All PL/SQL functions use explicit cursors, so every select statement is managed within a cursor which is explicitly closed when the function finishes with it.
    From v$open_cursor, I identified the sessions with the cursors still open, and issued (ALTER SYSTEM KILL SESSION �sid, #serial�) for each of the sessions (this is done via a PL/SQL function for all inactive sessions).
    These sessions have state INACTIVE, and wait_class IDLE. This has Killed all sessions, but I was not able to use the application anymore. I suspect by killing those sessions we have also caused the connections between EJB container and the Oracle DB. The only way to use the application now is to stop and restart the sunONE domain � this is very inconvenient.
    Has anyone encountered a similar problem? any suggestions to reduce or eliminate the open cursors number? Please help.
    Thank you all

    Maybe you can try to have a smaller steady-pool-size and idle-timeout-in-millis for your connection pools.
    Also, if that's at all possible, have smaller number of connection pools being shared by more apps.
    Just my 2c.
    thanks.

  • Oracle - maximum open cursors exceeded

    Hi! I'm constatly getting the error I pasted below, when this line is executed:
    PreparedStatement stmt = connection.prepareStatement(sqlStatement);
    'connection' is of course an instance of oracle.jdbc.driver.OracleConnection, and 'sqlStatement' is a normal INSERT statement.
    Now, why I'm getting an error that involves cursos if the statement is an insert? One more thing, this error is happening in some enviroments so I think it could be an orcacle server problem (like installation or configuration problem), or it could be the driver, or... I dont know :)
    Well, I hope anyone can give me a tipo about this... Thanks in advance.
    Dario
    ORA-01000: maximum open cursors exceeded
    java.sql.SQLException: ORA-01000: maximum open cursors exceeded
    at oracle.jdbc.dbaccess.DBError.throwSqlExceptionDBError.java:180)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
    at oracle.jdbc.ttc7.Oopen.receive(Oopen.java:118)
    at oracle.jdbc.ttc7.TTC7Protocol.open(TTC7Protocol.java:472)
    at oracle.jdbc.driver.OracleStatement.<init>OracleStatement.java:499)
    at oracle.jdbc.driver.OracleStatement.<init>OracleStatement.java:518)
    at oracle.jdbc.driver.OraclePreparedStatement.<init>OraclePreparedStatement.java:210)
    at oracle.jdbc.driver.OraclePreparedStatement.<init>OraclePreparedStatement.java:193)
    at oracle.jdbc.driver.OracleConnection.privatePrepareStatementOracleConnection.java:869)
    at oracle.jdbc.driver.OracleConnection.prepareStatementOracleConnection.java:704)
    ------------------------------------------

    Thanks a lot for all the answers...
    After some tests a made, I found out that in the enviroment I developed the application, the value of the parameter OPEN_CURSORS is 300. I don't know yet which is the value in the test enviroment (where the errors are happening) but I'm pretty sure it is smaller, since I could force the same error in the development enviroment increasing the concurrency of the application (ie, I force the application too many create prepare statements, even much more than the real values the application should accept).
    Well, I have to thank you all again...
    Dario

  • Recommended OPEN CURSORS setting for Oracle serving a web app

    G'day
    Hopefully Phil is still lurking here, so might see this.  Or anyone else that knows about Oracle.
    I've always thought the default for "maximum pooled statements" setting for an Oracle DSN - which is 300 - is way too low to be sensible for a web app (which, let's face it, any CF DSN is going to be used for!).  I usually find I end up with it up around 1000-2000, depending on the sizeof the app, and how busy it is.
    I'm adequate with monkeying around with Oracle, and have needed to do a moderate bit of that sort of thing in our dev environment, but I am by no means a DBA, so it's all very seat-of-the-pants.
    So I'm keen to know what other people have their maximum pooled statements / open cursors setting set to for their Oracle-driven web sites/apps.
    One of the reasons I'm asking is that I wonder if it might be worth while to suggest the default for CF9 is upped to 1000 or so..?
    Thoughts / comment?
    Adam

    I personally would not set the limit any higher than 300, and I'd consider keeping it even lower.
    Each pooled query / open connection is imposing resource-burdens on both the CF and the Oracle servers by creating what might be thought of as "a very crowded restaurant."  Most of them are just standing around, but they nevertheless are occupying the restaurant, and the potential exists that every one of them might try to order a burger-and-fries at exactly the same time.
    The "number of pooled statements" should be such that your SQL-server can actually handle that number of simultaneous requests, both in terms of active searches and of maintaining the still-open result sets.  Beyond that point, incoming web requests should be forced to wait.  Set an "occupancy limit" to your proverbial restaurant such that everyone could come in and be timely served at the same time.
    Categorically, if you plot out response-time graphs about such things (SQL servers, virtual memory subsystems, and so on), they exhibit a fairly-linear performance curve up to a point, after which "the elbow- or knee-point is reached" and beyond that point it becomes exponential in a very, very bad way.  I saw this happen in a batch-processing subsystem long ago on a very small mainframe:  (yeah, I'm makin' these numbers up...)
    Number of Jobs at Once
    Completion Time per Job
    1
    30 seconds
    3
    40 seconds
    8
    9 minutes
    12
    4.5 hours
    It was just-about that bad.  And what I did to (dramatically...) address the problem was to impose simultaneous-job limits on that subsystem.  As long as the number of simultaneous jobs was constrained to "less than 3 at a time," a workload of 12 jobs could be reliably completed in (4 * 40) seconds, whereas if all 12 jobs tried to run at once, the computer would have reason to file a lawsuit for abuse.

  • Oracle database open cursor created by clob.getCharacterStream()

    I cannot close open cursor created by clob.getCharacterStream();
    I use the following code. Please note that I close the Reader Stream.
    Since my database connection is pooled I cannot close the connection to close the cursor. SQL_TEXT field in v$open_cursor shows "table_4_200_1862_0_0_0" or some thing like that.
    Thanks in advance for any reply.
    public static String readClob( Clob clob )
    StringBuffer bufCLOB = new StringBuffer();
    int nbytes = 0;
    char[] buffer = new char[ 32768 ];
    try
    java.io.Reader clobReader = clob.getCharacterStream();
    int len = 0;
    while( ( len = clobReader.read( buffer ) ) != -1 ){
    bufCLOB.append( buffer, 0, len );
    clobReader.close();
    catch( Exception ex )
    ex.printStackTrace();
    return bufCLOB.toString();
    }

    I found the reply from somewhere. It seems implecit open cursors donot count to maximum allowed one. While updaint clob fields oracle opens implecit open cursors.

  • Upgraded to 64 bit Oracle DataAccess.dll and now more open cursors errors

    Hi, We recently converted from .net framework 1.1 application to .net 4.0 framework for 64 bit. We installed the 64 bit version of Oracle DataAccess dll. It now seems like we are getting many more open cursor error messages in our application. The open_cursor value set in the database has not changed and other than the 64 bit Oracle and .net 4.0 framework nothing has changed. I was just curious if anyone else that has converted to the 64 bit Oracle DataAccess dll has experienced an increased number of open cursor errors? If so, what was the resolution.
    I apprecieate any feedback.
    Thanks

    What do you have /32BIT flag set to in the assembly? Ie, was it compiled with AnyCPU, x86, etc? You can use corflags.exe with the .net sdk to find out.
    Prior to VS2010, the default was AnyCPU which meant it ran as 64 bit on 64 bit OS, and 32 bit on 32 bit OS.
    As of VS2010, the IDE defaults to x86, which means it runs as 32 bit no matter what.
    32 bit apps need 32 bit odp/client. 64 bit apps need 64 bit odp/client.
    The error you're getting usually means you have the wrong bits (32/64) of the Oracle client installed.
    Assuming you have the wrong client bits installed, you could either
    a) make the app run as the other bits by setting/clearing the 32BIT flag (also by using corflags.exe)
    b) install the other bits of Oracle client software. a 32 bit home and a 64 bit home play rather nicely together for the most part, but you need to install them into separate homes.
    Hope it helps,
    Greg

  • Open cursors exceeded - common problem, different scenario

    I searched both the web and the java forums and found the "maximum open cursors exceeded" to be a very common problem, one in which I have, but I can't seem to solve it and I was wondering if the way I am doing certain things are causing it.
    Here is my program. I have a java server running that is acting as a midway between a java applet and an Oracle database. Since many users will most likely be using the applet, and since the applet has the ability to alter data in the database, I wanted to Synchronize my database connections.
    So because of this, my server has a static class with all the database calls, including a connection call that connects to the database when it is first started up. Also, I return ResultSets to the server, but I never close either my ResultSet or my Statement. I do this because I only have one global of each of them. Otherwise I would have to close them from the server, and this worries me as far synchronization goes. Thus, with a global statement, I am just reinstantiating it every time. This may very well be my problem.
    Should I?
    1. Not have a single connection to the database but instead create a new connection every time a database call is made?
    2. Do not make the resultset and statement global. (And if this is yes, how would I go about closing them after I return the result set to the server).
    3. Leave the resultset and statement global but go ahead and try to close them from the server.
    4. Or any combination of the above.
    Thanks. I appreciate any help advance. This problem has been driving me insane the last couple of days. If it would help to post my database connections code then I will gladly do so.

    Hmmm. I have worked on it all day and still have nothing. If anyone has even a shred of help, that would be greatl appreciated. I am going to just go ahead and post my code just in case that helps anyone.
    import java.net.*;
    import java.sql.*;
    import java.io.*;
    import oracle.jdbc.driver.*;
    class DBOracleCon
         final static String          DBHostName = "hostname",
                             DBPortNumber = "12345",
                             DBId ="myid";
         final static String          UserName = "user",
                             Password = "password";
         private static Connection con;     
         private static Statement stmt;     
         private static ResultSet rs;
         static protected void dbConnection ()
              try
                   DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                        String dbConnectString =
                        "(DESCRIPTION=(ADDRESS=(HOST=" + DBHostName + ")"+
                        "(PROTOCOL=tcp)(PORT="+ DBPortNumber + "))"+
                        "(CONNECT_DATA=(SID="+ DBId + ")))";
                   con = DriverManager.getConnection(
                            "jdbc:oracle:thin:@"+dbConnectString,
                            UserName, Password);
                          con.setAutoCommit(false);
              catch (Exception e)
                   System.out.println ("Connection Error:" + e);
         static public synchronized Connection returnConnection ()
              return con;
         static protected synchronized ResultSet executeQuery (String query)
              try
                   stmt = con.createStatement();
                   //System.out.println ("QUERY: " + query);
                   rs = stmt.executeQuery (query);
                   return rs;
              catch (Exception e)
                   System.out.println (e);
                   e.printStackTrace();
                   return null;
         static protected synchronized ResultSet executeQuery (PreparedStatement ps)
              try
                   rs = ps.executeQuery();
                   return rs;
              catch (Exception e)
                   System.out.println (e);     
                   e.printStackTrace();
                   return null;
         static protected synchronized void executeUpdate (String query)
              try
                   stmt = con.createStatement();
                   System.out.println ("UPDATE: " + query);
                   stmt.execute (query);
                   commit();
              catch (Exception e)
                   System.out.println (e);
                   e.printStackTrace();
         static protected void executeUpdate (PreparedStatement ps)
              try
                   ps.executeUpdate();
                   commit();
              catch (Exception e)
                   System.out.println (e);     
                   e.printStackTrace();     
         static private void commit ()
              try
                   stmt = con.createStatement();
                   stmt.execute ("commit");
              catch (Exception e)
                   System.out.println (e);
    }Thanks.

  • Cannot figure out why "ORA-01000 Maximum open cursors" is shown...

    Hello there ...
    I am programming a PL/SQL Code that is throwing 0RA-01000 Maximum Open Cursors Exceeded.
    Having already read quite a lot about ORA-01000 errors, I know I should be closing cursors, and have already tried setting OPEN_CURSORS parameter to a high number (1000).
    I declared a lot of procedures in my pl/sql, each of which uses one cursor since i am working with a non-Oracle table linked by ODBC ... and each procedure sometimes does thousands of inserts -- but all WITHIN the explicit cursors. The explicit cursors are not declared within each loop.
    I already checked the code many times, and made sure all open cursors are closed. In addition, I also verified the numberopen cursors generated by the PL/SQL by running the following SQL after every procedure i run... and outputting it... and it appears the value just keeps on increasing, even though I had explicitly closed all the cursors in all the earlier procedures.
    What is funny is that the most number of cursors reported by the code below only hits 150+ cursors. Nowhere near the 1000 open_cursors limit per session.
    select a.value into strtxt --, b.name        
            from v$mystat a, v$statname b
            where a.statistic# = b.statistic#
            and a.statistic#= 3;When I run the procedures separately though, all the procedures run smoothly (even when I had not yet updated the open_cursors parameter).
    I was thinking of the following, but maybe you have some other ideas?
    Does this have anything to do with my procedures not being stored procedures?
    Or should i be committing records within my procedures instead of out of it?
    I really have run into a wall and would really appreciate any tips or helps on this. Thanks in advance!
    My basic pl/sql code looks like below. I did not give the actual details cause it will be too long (up to 5000 lines).
    DECLARE
    PROCEDURE proc1
    IS
        CURSOR cur_hca
           is
               select ...from..where;
       TYPE cur_hca_fetch
            Is TABLE OF cur_hca%ROWTYPE
                INDEX BY PLS_INTEGER;
        temp_collect cur_hca_fetch;
    BEGIN
       open cur_hca;         --cur_hca is the cursor name.
                                      --i use exactly the same cursor name in the other procedures
          loop
             fetch cur_hca bulk collect into temp_collect LIMIT 1000;
             exit when temp_collect.count=0
             for indx in 1 .. temp_collect.count
                loop
                  ...run some sql
                end loop;
          end loop;
      close cur_hca;
    END proc1;
    PROCEDURE proc2   --almost the same as above the only changes are the query for the
                                 -- cursor and the sql that happens for each record
    IS
    BEGIN
       open cur_hca;         --cur_hca is my cursor name
          loop
          end loop;
      close cur_hca;
    END proc2;
    ... up to 40 other very similar procedures
    BEGIN
       proc1;
       commit;
       select a.value into strtxt
            from v$mystat a, v$statname b
            where a.statistic# = b.statistic#
            and a.statistic#= 3;
      DBMS_OUTPUT.PUT_LINE('Number of Cursors After STATUSproc1: ' || strtxt); 
       proc2;
       commit;
       select a.value into strtxt
            from v$mystat a, v$statname b
            where a.statistic# = b.statistic#
            and a.statistic#= 3;
       DBMS_OUTPUT.PUT_LINE('Number of Cursors After STATUSproc2: ' || strtxt); 
       ... 40 other procedures
    END;Edited by: user4872285 on May 6, 2013 6:49 PM
    Edited by: user4872285 on May 6, 2013 7:01 PM
    Edited by: user4872285 on May 6, 2013 8:02 PM
    Edited by: user4872285 on May 6, 2013 8:03 PM

    PL/SQL code usually leaks reference cursors and DBMS_SQL cursors - as the ref cursor/DBMS_SQL interface used has a global (session static) scope.
    PL/SQL has an intelligent garbage collector that will close local implicit and explicit cursors, when the cursor variable goes out of scope.
    If you define an explicit cursor globally (package interface), then it can only be opened once. The 2nd attempt results in a ORA-06511: PL/SQL: cursor already open exception. So code cannot leak explicit cursors as code cannot reopen an existing opened explicit cursor.
    I have never seen Oracle leaking cursors internally. So I would be hesitant to call what you are seeing, a bug. If your code is using explicit cursors (even static/global ones), your code cannot leak these cursors, even if your code does not close them. Worse case - the cursor remains open, however new copies cannot be created while it is open.
    So I think your are looking at the wrong thing - explicit cursors. These are not the cursors that are leaking in my view (simply because code cannot reuse and open an already opened explicit cursor). Here is an example:
    SQL> show parameter cursors
    NAME                                 TYPE        VALUE
    open_cursors                         integer     300
    session_cached_cursors               integer     50
    // procedure that seems to "leak" an explicit cursor handle
    // as it does not explicitly closes the handle
    SQL> create or replace procedure CursorUse is
      2          cursor c is select e.* from emp e;
      3          empRow  emp%RowType;
      4  begin
      5          open c;
      6          fetch c into empRow;
      7          --// not closing explicit cursor handle
      8          --// and going out-of-scope
      9  end;
    10  /
    Procedure created.
    // current session stats
    SQL> select b.name, a.value from v$mystat a, v$statname b where a.statistic# = b.statistic# and b.name like '%open%cursor%';
    NAME                                  VALUE
    opened cursors cumulative                91
    opened cursors current                    2
    // execute proc that "leaks" a cursor, 10000 times
    SQL> begin
      2          for i in 1..10000 loop
      3                  CursorUse;
      4          end loop;
      5  end;
      6  /
    PL/SQL procedure successfully completed.
    // no errors due to cursor leakage
    // session stats: no cursor leakage occurred as
    // PL/SQL's garbage collector cleaned (and closed)
    // cursor handles when these became out-of-scope
    SQL> select b.name, a.value from v$mystat a, v$statname b where a.statistic# = b.statistic# and b.name like '%open%cursor%';
    NAME                                  VALUE
    opened cursors cumulative            10,095
    opened cursors current                    2
    SQL> So the cursor leakage you are seeing is caused by something else... so what else is part of the code, or the session, that you have not yet mentioned?

Maybe you are looking for

  • Home Sharing with multiple iTunes accounts

    I have set up Home Sharing between our iMac and our AppleTV2 using my wife's Apple ID. The AppleTV sees my wife's iTunes library and plays music from it. However, my wife has songs in her library purchased under both her iTunes account and my iTunes

  • Adobe Media Encoder cc crash

    Adobe Media Encoder becomes unresponsive if i try to add more than one file to the queue. This occurs by drag and drop of using the file explorer method. It ebven hangs in the same way if a video has finished processing and another one is added right

  • Email submit button doesn't work after digitally signing document

    I have a PDF fillable form that works great except for the digital signature fields. Every employee needs to fill it out, sign it, hit the email submit button to faward it to the boss, who then signs it and saves it. There are two digital signature f

  • How to highlight tree item ?

    Hello everybody ! I have a question : how to highlight a tree item on a condition ? (please see the attached vi and the pictures for a clearer explanation of the problem) I am using LabView 2014. Thank you very much ! Solved! Go to Solution. Attachme

  • Adding subtitles (.srt) to an avi file permanently.... also combining files

    I have a movie in french that i am able to view with subtitles in vlc but i want to be able to convert the avi files into mpeg-4 so im not sure how to combine the subtitles and the video together. Also, since the movie is in two parts i was wondering