Maximum open Cursors Excedded error - for every transaction

Hi All,
I am getting the maximum opn cursors exceeded error suddenly for every single db transaction i am trying to make in my application. this did not happen previously during my developemnt and testing phase.
I have a question here that i tried to google but failed to get satisfactory answer.:-
When we use a cursor in the stored procedure to fetch data, how to make oracle automatically close the cursors once the stored proc finishes executin. Or is there something i have to follow other with my current open cursors limit to ensure this problem does not happen?
Thanks,
Chaitanya

Hi Justin,
My oracle stored procs are called by java framework. In each place i was closing the connection object but there were a few places where i was not closing the resultset object which directly pointed to my oracle cursor.
I have closed the objects in such places and tried again but still i am getting the same error. Mit it be an instance where the oracle db is not allowing me to connect to it at all. Something like restarting it would help? Restarting the server where the oracle software is hosted.
Please excuse my blatant ignorance in this issue.
Thanks,
Chaitanya

Similar Messages

  • ORA-01000: maximum open cursors exceeded--Error

    Hi
    What is "ORA-01000: maximum open cursors exceeded" error,How to solve.
    Thanks
    Miseba

    Hi
    ORA-01000: maximum open cursors exceeded
    Other terms
    Oracle, open cursors, exchange infrastructure
    Reason and Prerequisites
    The parameter "open_cursors" is set too low. Long transactions, such as imports, may use up all available cursors and fail.
    Solution :
    THIS NOTE APPLIES TO XI 3.0 SP2 ONLY **
    if you encounter an exception that reports "ORA-01000: maximum open cursors exceeded" please adjust the open_cursors parameter as follows:
    If the BR*Tools exist on your system:
    1] directory: /usr/sap/<SID>/SYS/exe/run
    2] "brspace -c force -f dbparam -a change -p open_cursors -v 100000"
    3] directory: $ORACLE_HOME/dbs (Unix) or %ORACLE_HOME%/database (Win)
    4] change open_cursors parameter in init<SID>.ora to 100000
    If the BR*Tools are not available (2] above - command not found)
    1] change the open_cursors parameter as in 4] above
    2] restart DB, for changes to take effect. _ NOTE: This problem has been fixed with XI 3.0 SP3 (see note 735078)
    Plz asign points if helpfull.
    Regards
    Padmanabha

  • Maximum Open cursor  Exceeded error when deleting records from a table

    I have a strange problem.
    I have a table EMP_MASTER . Whenever I am trying to delete a record from this table, I am getting Maximum no. of open cursor exceeded error. But this error doesnot come when i delete from any other tables. And no. of open cursor is much lesser than OPEN_CURSOR parameter.
    All other tables (around 700) has foreign key constraint to this EMP_MASTER table for created_user paramater.
    Is it some thing like, when I am trying to delete a record from EMP_master, implicit cursor opens up and checks all referenced tables. and that limit gets exceeded ?
    Please help.
    Thanks,
    Raj

    Raji03 wrote:
    There is no trigger defined for this table.
    Is there a limit on which no.of references made to a column ? Because one column in this field, Emp no is being referenced in almost every other table. around 700 tables. Will it have any adverse effect ?That should have nothing to do with your problem directly. Again, those tables could have triggers defined on them and you are leaking cursors in one of those triggers (wild guess).
    An example of a table with many many others foreign key'd to it.
    create table parent_of_everything
       column1 number primary key
    insert into parent_of_everything select level from dual connect by level <= 1000;
    commit;
    --create 1000 tables all with foreign keys to the parent_of_everything
    begin
       for i in 1 .. 1000
       loop
          execute immediate 'create table child_' || i || ' (column1 number, column2 number, constraint child_' || i || '_fk foreign key (column1) references parent_of_everything (column1) on delete cascade)';
          execute immediate 'insert into child_' || i || ' select level, mod(level, ' || i || ') from dual connect by level <= 1000';
          commit;
       end loop;
    end;
    TUBBY_TUBBZ?delete parent_of_everything;
    1000 rows deleted.
    Elapsed: 00:02:53.03No problems were had (none were expected).
    Cleanup script.
    --remove the 1000 child tables
    begin
       for i in 1 .. 1000
       loop
          begin
             execute immediate 'drop table child_' || i || ' purge';
          exception when others
             then
                null;
          end;
       end loop;
    end;
    /

  • Error : Maximum Open Cursors Exceded

    Hi!
    The error appear in that check out or check an objet using OSCM. At first I cna do it but when i trying to check in or out files the messages appear. I don´t understand why and for waht action it appear.
    Any suggestion??
    Thanks!
    Matias

    Did you increase the max open cursors to 3000 as recommended in the OracleSCM install guide?
    Rob

  • JDBC Error: ORA-01000: maximum open cursors exceeded

    Post Author: prashant
    CA Forum: Information OnDemand
    I successfully created reports using CR4E on windows, deployed JSPS to Websphere running on windows and was able to view a large reports for a using JNDI connection resources to Oracle 10g.
    Every time report is called, it consume 12 cursors from of the database. Open_cursors count is 300. After 24 or 25 iteration of this report, it throws ORA-01000: maximum open cursors exceeded error.
    Has anyone seen this problem, and if so where can I find a hot fix/patch. Any help would very much be appreciated.

    The following code reproduces the problem for me. I thought this was just related to when an exception occurs, and close occurs immediately afterwards. Close finds the exception that occured, and throws it without releasing the resources.
    It's a pain in the ass, that's for sure.
    public void go() {
    try{
    long startTime = System.currentTimeMillis();
    String sql = "Select number_7_0__, char_10__, varchar_5__, varchar2_10__, number_10_5__, float_126__, date_, clob_, blob_ FROM lotsofrows";
    Properties connectProps = new Properties();
    Driver drv = new oracle.jdbc.driver.OracleDriver();
    connectProps.put("user", "borg");
    connectProps.put("catalog", "test");
    connectProps.put("password", "borgborg");
    Connection conn = drv.connect("jdbc:oracle:thin:@142.176.134.166:1521:test", connectProps);
    int cnt = 0;
    while (true) {
    try {
    System.out.print("\nTest " + ++cnt + " ");
    Statement stmt = conn.createStatement();
    System.out.print("execute ");
    ResultSet rs = stmt.executeQuery(sql);
    System.out.print("cancel ");
    stmt.cancel();
    try {
    System.out.print("close.");
    stmt.close();
    } catch (SQLException se) {
    if (se.getMessage().indexOf("requested cancel") != -1) {
    System.out.print("URC:Close");
    try {
    stmt.close();
    } catch (Exception ee) {
    System.out.println(ee.getMessage());
    ee.printStackTrace();
    } else {
    throw se;
    stmt = null;
    }catch(Exception se) {
    System.out.println(se.getMessage());
    se.printStackTrace();
    }catch(Exception e) {
    System.out.println(e.getMessage());
    e.printStackTrace();
    null

  • 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 with the CachedRowSet

    Hi all,
    I have a simple task that is cause significant headaches. I'm using the CachedRowSet to process records from an Oracle 8.1.6 database. The code simply populates the row set with records, makes changes to 2 or 3 fields in each record, then calls the acceptChanges().
    When I process about 200 records, everything works fine. If I try to process 300 records, I get the error
    "ORA-01000: maximum open cursors exceded".
    Right before the acceptChanges is called, there is only 1 cursor opened ( I'm checking this via the V$OPEN_CURSOR table). After the acceptChanges is called, it throws the error. Inside my catch block, I put a loop in to print the open cursors. All but two of them is from my app and showing the exact same SQL, update table set name ....
    I have tried populating it directly and through a ResultSet, neither work. When I do a similar process using a ResultSet by itself, it is fine.
    If anyone could please suggest what I might be overlooking I would appreciate it. Also, I would also like to know if there is someway to examine the specific SQL that is being sent to the database if possible.

    we've had similar problems with Oracle creating and not destroying its own cursors("under the covers"). There is relevant info at the following link:
    http://forums.java.sun.com/thread.jsp?forum=48&thread=135291
    quick checklist:
    1. close all statements/preparedstatements/resultsets explicitly and immediately after you are finished with them
    2. increase your number of open_cursors in init.ora file
    -->we had to increase ours to over 700 at one point.
    3. commit/rollback explicitly when finished transactions.
    hope this helps
    Jamie

  • ORA-01000 maximum open cursors exceeded with XA driver

    We are getting ORA-01000 maximum open cursors exceeded error from Oracle database
    agian and again.We are usimg XA driver.
    What is the weblogic's work around to handle this error?How we can handle this?We
    tried doing "grant select on DBA_PENDING_TRANSACTIONS to public ;" ,this also
    works for some time only.Again the same error starts coming.
    Help please.
    Thanx in advance.

    Thanks for your reply.
    I have increased my cursor size to 2000(default 300).We are using weblogic6.1
    and Oracle9i.Yes I was little aware about this bug so I tried doing "grant select
    on DBA_PENDING_TRANSACTIONS to public " from sys and no of open cursors reduced
    drastically but aftter some time increased again.We are using combination of thin,XA,non
    XA and oci drivers.
    We are using weblogic security framework also in our application and I think that
    consumes maximum no. of cursors.
    Kindly advice.
    Thanx a lot.
    Pinky
    Mitesh Patel <[email protected]> wrote:
    What is the size of cusror set in your oracle init.ora file?
    What version of oracle thin driver and weblogic are you using?
    Please read the following note:
    There is a bug with Oracle 817 driver's XAResource.recover implementation:
    it
    ignores the flag and always return all in-doubt Xids. After initially
    calling a resource's recover with TMSTARTRSCAN, TM subsequently calls
    the
    resource's recover with TMNOFLAGS until no more Xid is returned. Thus,
    Oracle driver's XAResource.recover is called infinitely until eventually
    it
    returns XAER_RMERR. Subsequent XAResource.start then returns ORA-01000
    exception (looks like all their XAResource methods internally uses prepared
    statements to execute some stored procedure.)
    Is this the case wth you?
    Mitesh
    Pinky Arora wrote:
    We are getting ORA-01000 maximum open cursors exceeded error from Oracledatabase
    agian and again.We are usimg XA driver.
    What is the weblogic's work around to handle this error?How we canhandle this?We
    tried doing "grant select on DBA_PENDING_TRANSACTIONS to public ;",this also
    works for some time only.Again the same error starts coming.
    Help please.
    Thanx in advance.

  • ORA-01000: maximum open cursors exceeded In a Package

    I have a package that is utilizing cursors, This program is for a data conversion project. I have Ten procedures and functions in this package, about 4 of them are public. Within my main program I call these functions and procedures as needed. After about the processing of 30 records, i get this 'ORA-01000: maximum open cursors exceeded' error. the curosr parameter on the database is 300, I am not sure what to do, the cursors are closed, because I am usuing the cursor for loop. I have changed these cursors from ref to regular cursors, but the problem persist. Could someone please help! Thanks.

    there are about 6000 lines of code here is an example. I have checked all cursors and they are closed after processing.
    -- Package Spec
    Package MainPac Is
    Procedure c1;
    End MainPac;
    -- Package Body
    Package MainPac Is
    Procecudure P2( InputP ) is
    Cursor c2 is select * from SiteRec
    Where NJSKey = InputP;
    For c2Rec In C2 Loop
    Process c2Rec;
    For C3Rec in (Select Remart Text from all_remarks
    Where remark_Key = C3Rec.Key) Loop
    Load into tem table;
    End loop;
    end Procedure P2;
    Procecudure P3( InputP ) is
    Cursor C4 is select * from SolutuinsTab
    Where NJSKey = InputP;
    For C4Rec In C4 Loop
    Process C4Rec;
    For C5Rec in (Select Remart Text from all_remarks
    Where remark_Key = C4Rec.Key) Loop
    Load into tem table;
    End loop;
    end Procedure P3;
    Procedure c1 is
    Cursor c1 is Select * from NJS;
    begin
    For c1rec in c1 loop
    process c1rec;
    call procecudure P2(NJSKey);
    call procecudure P3 (NJSKey);
    call procecudure P4(NJSKey);
    call procecudure P5(NJSKey);
    call procecudure P6(NJSKey);
    end loop;
    End MainPack ;

  • ORA-01000: maximum open cursors exceeded in R12

    Hi,
    In which Middle Tier log we see "ORA-01000: maximum open cursors exceeded" error, we have EBS R12 version.

    937828 wrote:
    Hi,
    In which Middle Tier log we see "ORA-01000: maximum open cursors exceeded" error, we have EBS R12 version.
    Increase the value of OPEN_CURSORS init parameter -- https://community.oracle.com/search.jspa?peopleEnabled=true&userID=&containerType=&container=&q=ORA-01000
    Database Initialization Parameters for Oracle E-Business Suite Release 12 (Doc ID 396009.1)
    Thanks,
    Hussein

  • In java/jsp got Error,ORA-01000: maximum open cursors exceeded,

    Dear ALL,
    We are facing a problem of in java/jsp. ORA-01000: maximum open cursors exceeded,We are using referance Cursor for returing the Record in java file.
    The Code is given below.
    import java.sql.*;
    import javax.sql.*;
    import com.india.trade.dbConnection.*;
    import oracle.jdbc.driver.*;
    import java.util.Vector ;
    public class IntRmsActivity
         private static JDBCConnection instance = null;
    private static Connection con = null;
         private static CallableStatement stmt_admin_getadmins = null;
         private static String str_admin_getadmins = "{ call Admin_conf.RMS_ADMIN_GETALLADMINS(?,?) }";
         static
              try
                   instance = new JDBCConnection();
                   con = instance.getConnection();
                   stmt_admin_getadmins = con.prepareCall(str_admin_getadmins);
    }catch(Exception se){se.printStackTrace();}
         public static Vector admin_getAdmins() throws Exception
              checkconnection();
              String message = null;
              Vector v_admins = new Vector();
              ResultSet rs_admins = null;
              stmt_admin_getadmins.registerOutParameter(1 , OracleTypes.CURSOR);
              stmt_admin_getadmins.registerOutParameter(2 , Types.VARCHAR);
              stmt_admin_getadmins.execute();
              message = stmt_admin_getadmins.getString(2);
              System.out.println("message " + message);
              rs_admins = ((OracleCallableStatement)stmt_admin_getadmins).getCursor(1);
              while (rs_admins.next())
                        v_admins.addElement(rs_admins.getString("adminid"));
              rs_admins.close();
              return v_admins;
    CREATE OR REPLACE PACKAGE Admin_conf IS
    TYPE REF_CRSR IS REF CURSOR; /* OUTPUT CURSOR VARIABLE TYPE */
    PROCEDURE RMS_ADMIN_GETALLADMINS(RESULTS OUT REF_CRSR,
                                            OUT_MESSAGE OUT VARCHAR2);
    END Admin_conf;
    CREATE OR REPLACE PACKAGE BODY Admin_conf
    IS
    PROCEDURE RMS_ADMIN_GETALLADMINS(RESULTS OUT REF_CRSR,
                                            OUT_MESSAGE OUT VARCHAR2)
    IS
    l_ref_out_crsr REF_CRSR;
    BEGIN
         OPEN l_ref_out_crsr FOR
         SELECT EXECUTIVE_ID adminid
         FROM MASTER_EXECUTIVE_ID
         ORDER BY EXECUTIVE_ID;
         OUT_MESSAGE := 'ADMIN IDS FETCHED SUCCESSFULLY';
         RESULTS := l_ref_out_crsr;     
    EXCEPTION WHEN OTHERS THEN
              OUT_MESSAGE := 'ERROR ' || SUBSTR(SQLERRM, 1, 60);
    END RMS_ADMIN_GETALLADMINS;
    END Admin_conf;
    Regards
    Ajay Singh Rathod

    Are you actually closing the connections, resultsets in all cases?
    From what you've posted you call
    rs_admins.close();but in that method, you propagate any exceptions that occur out to the caller method, which in turn just prints a stack trace.
    So if an exception occurs before you call the rs_admin.close() the result set will never be closed as the statement won't be reached.
    I'd add a speific exception handling routine to the admin_getAdmins() method and include a finally clause to close the result set in all cases. You can still onthrow the exception if you want.
    cheers
    -steve-

  • Getting error ora-01000 maximum open cursors exceeded

    hello,
    i am building my fist application using eclipse3.3 hibernate 3.2(hybernatesynchronizer as plugin)
    i have a oracle9i like sgbd . when i trying to create my mapping file from eclipse i got this error :
    ORA-01000: maximum open cursors exceeded
    i try to increase the number of cursor from the oracleconfiguration file init.ora, i shutdown but the problem still
    i don t know how to solve this problem really.
    i need help.

    Yes, that it what I was asking about.Not that it matters, but I think you misunderstood. I meant "if you ask it to leak resources then it will do so." I wasn't asking what you meant.
    Is there a way to make it explicitly open and close via a single call? Perhaps a configuration option either globably or by method/class?Not as a standard part of Hibernate, no. That said, it's relatively hard to leak anything other than connection objects unless you're really trying hard. There are libraries that you can use to manage the lifetime of the connection (actually the session) object. I like the Spring DAO support classes. Inevitably they cause their own problems for someone who doesn't understand what Hibernate's up to under the covers though.
    Edit: Quick example
    // Bog standard Hibernate
    Session session = sessionFactory.openSession();
    try {
       return (List<Foo>)session.createQuery("from Foo").list();
    } finally {
       session.close(); // If omitted will leak a connection object
    // Using Spring
    return (List<Foo>)getHibernateTemplate().find("from Foo");Things get slightly more interesting if you're using lazy loading and actively want to keep the connection around for longer.

  • Error ORA-01000: maximum open cursors exceeded

    Why Oracle return this error. When I change the OPEN_CURSORS in init.ora from 100 to 1000 without this error.
    I want to keep Minimum cursors value. How can I change the Java program ?
    96 er_write_asp('W349','HK','50112','USD',3.99)
    97 er_write_asp('W349','HK','10112','USD',5.22)
    98 er_write_asp('W349','HK','60112','EUR',13.07)
    99 er_write_asp('W349','HK','50112','USD',3.9)
    100 er_write_asp('W349','HK','40112','USD',5.65)
    101 er_write_asp('W349','HK','90112','USD',2.75)
    java.sql.SQLException: ORA-01000: maximum open cursors exceeded
    ORA-06512: at "POSTCAL.ER_WRITE_ASP", line 10
    ORA-06512: at line 1
    java Program list.
         eric.leung 2003/12/02
         set CLASSPATH include C:\Oracle\Ora81\jdbc\lib\classes12.zip
         Purpose
         ===============
         Read text file, write into Oracle Database
    import java.io.*;
    import java.util.StringTokenizer;
    import java.sql.*;
    import java.lang.*;
    import java.math.BigDecimal;
    import java.util.Date;
    public class writeASP {
    // Login Information
    static String user = "x";
    static String passwd = "x";
    static String ip = "x";
    static String getfile = "c:\\temp\\asp.csv";
    public static void main(String[] args) throws IOException {
         String line;
         int i = 0;
         int cnt = 0;
         int port = 0;
         Connection conn;
         Statement stmt;
         String query = "";
         String strone = "";
         String arry[] = {"","","","","","","","","","","","","","",
         // start to connection
         chkArgs(args);     
         FileReader inFile = new FileReader(getfile);
         BufferedReader in = new BufferedReader(inFile);
         try {                
         Class.forName("oracle.jdbc.driver.OracleDriver");
         conn = DriverManager.getConnection("jdbc:oracle:thin:@" + ip + ":1521:lcdx",
              user,passwd);
         stmt = conn.createStatement();
         while((line= in.readLine()) != null)
                   cnt = cnt + 1;
                   StringTokenizer mot = new StringTokenizer(line,",");
              if (mot.countTokens() > 0) {                   
                        for (i = 0; 0 < mot.countTokens() ;i++) {
                             arry[i+1] = "";
                             arry[i] = mot.nextToken();
                        } /* for */
                   } /* if */           
                   strone = arry[0].substring(0,1);
                   if (strone.equals("W")) {
                        //abc(arry);
                        query = "er_write_asp(" +
                        quote(arry[0],',') +
                        quote(arry[1],',') +
                        quote(arry[2],',') +
                        quote(arry[3],',') ;
                        query = query + arry[4] + ")";               
                   System.out.println(cnt + " " + query);
                   CallableStatement cs = conn.prepareCall
                        ("{call er_write_asp(?,?,?,?,?)}");
                   cs.setString(1,arry[0]);
                   cs.setString(2,arry[1]);
                   cs.setString(3,arry[2]);
                   cs.setString(4,arry[3]);
              try {cs.setBigDecimal(5, new BigDecimal(arry[4])); } /*pur_cost */
              catch(NumberFormatException e) {cs.setDouble(5,0);}
                   // System.out.println("Call string: "+ cs.getString());
                   boolean flag = cs.execute();
                   // ResultSet rs = cs.executeQuery();
                   // stmt.executeUpdate();
                   } /* if */
         } /* while */
         conn.close();
         } /* try */
         catch (Exception e) {
              System.err.println(e.toString());          
              } /* Catch */
         in.close();     
    } /* main */
    public static void abc(String g[])
         System.out.print(g[0] + " " + g[1] + " "
              + g[2] + " " + g[3] + " " + g[4] + " "
              + g[5] + " " + g[6] + " " + g[7] + " "
              + g[8] );     
         System.out.println();
    private static String quote(String s)
         return "'" + s + "'";
    private static String quote(String s,char j)
         return "'" + s + "'" + j;
    public static void chkArgs(String[] args) {
         for (int j=0 ; j < args.length;j++) {
              if (args[j].trim().equals("-u")) {
                   if (j + 1 < args.length) {
                        try { user = args[j+1];}
                             catch ( Exception e) {}
              } /* if */
              if (args[j].trim().equals("-p")) {
                   if (j + 1 < args.length) {
                        try { passwd = args[j+1];}
                             catch ( Exception e) {}
              } /* if */
              if (args[j].trim().equals("-i")) {
                   if (j + 1 < args.length) {
                        try { ip = args[j+1];}
                             catch ( Exception e) {}
              } /* if */
              if (args[j].trim().equals("-f")) {
                   if (j + 1 < args.length) {
                        try { getfile = args[j+1];}
                             catch ( Exception e) {}
              } /* if */
              if (args[j].trim().equals("-h")) {
                   help();
                   System.exit(0);
              } /* if */
         } /* for */
    } /* chkArgs */
    public static void help() {
         System.out.println("\nWrite ASP Price Version 1.0 2003/12/02\n");
         System.out.println("Option:");
         System.out.println("\t-i IP Address");
         System.out.println("\t-u User name");
         System.out.println("\t-p Password");
         System.out.println("\t-f File name");
         System.out.println("\t-h Help");
         System.out.println("\nCall Oracle Stored Procdure");
         System.out.println("er_write_ASP(,,,,)");
    } /* help () */
    } /* Class */

    Don't create a new callable statement each pass through the loop. Create it outside the loop and set the parameters & exec inside the loop. Close the resultset each time. Close statement after loop.

  • The error:maximum open cursors exceeded,how to resolve it??

    the parameter is as following in oracle: open_cursors=300
    i write the following two methos get data from oracle db,after invote the methods many times,the program thrwos the exception named "maximum open cursors exceeded";why?how to resolve it?
    in my program ,i have closed the statment and resultset!
    the following is the code,and method a call mehtod b:
    mehtod a:
    //modeify the product and call mothod b
    public boolean modifyDVBProd(Integer prodIDInt,ProdRequestEn prod)
    boolean successB=false;
    Connection conn=...;
    if(conn!=null)
    try
    conn.setAutoCommit(false);
    //the following call method b
    successB=ProdOperateBL.getInstance().modifyDVBProd(conn,prodIDInt,prod);
    if(successB)
    conn.commit();
    else
    conn.rollback();
    catch(Exception e)
    successB=false;
    try
    conn.rollback();
    catch(Exception ex)
    ex.printStackTrace();
    e.printStackTrace();
    finally
    try
    conn.setAutoCommit(true);
    catch (SQLException ex)
    ex.printStackTrace();
    else
    successB=false;
    return successB;
    method b;��
    //modify products
    public boolean modifyDVBProd(Connection conn,Integer prodIDInt,ProdRequestEn prod)
    boolean successB=false;
    String sqlPriceStr="UPDATE pricemodelen pm SET pm.rentpricf=? WHERE pm.priceidl=(SELECT p.priceidl FROM producten p WHERE p.productidl=?)";
    String sqlProdStr="UPDATE producten p set pronamestr=?,prod_type=?,unidstr=?,catype_name=?,casid=?,entitle_code=?,validfrdt=?,validtodt=?,descstr=? WHERE P.productidl=?";
    String sqlProd_channelDelStr="DELETE FROM proden_channelen c WHERE c.productidl=?";
    String sqlProd_channelInsertStr="INSERT INTO proden_channelen(productidl,channel_id) VALUES(?,?)";
    PreparedStatement pstmt1=null;
    PreparedStatement pstmt2=null;
    PreparedStatement pstmt3=null;
    PreparedStatement pstmt4=null;
    int paramIndexInt=1;
    try
    //price
    pstmt1=conn.prepareStatement(sqlPriceStr);
    pstmt1.setDouble(paramIndexInt++,prod.getProdPriceD());
    pstmt1.setDouble(paramIndexInt++,prodIDInt.intValue());
    int priceResult=pstmt1.executeUpdate();
    //product
    pstmt2=conn.prepareStatement(sqlProdStr);
    paramIndexInt=1;
    pstmt2.setString(paramIndexInt++,prod.getProdNameStr()); //product name
    pstmt2.setInt(paramIndexInt++,prod.getProdTpInt());//product type
    pstmt2.setString(paramIndexInt++,prod.getPriceUnitStr());//unit
    pstmt2.setString(paramIndexInt++,prod.getCaTpStr());//type
    pstmt2.setInt(paramIndexInt++,prod.getCasidInt());//casid
    pstmt2.setString(paramIndexInt++,prod.getCaEntitleCodeStr());//caentitlecode
    pstmt2.setDate(paramIndexInt++,prod.getValidBeginDate());//time
    pstmt2.setDate(paramIndexInt++,prod.getValidEndDate());//time
    pstmt2.setString(paramIndexInt++,prod.getProMemoStr());//memo
    pstmt2.setInt(paramIndexInt++,prodIDInt.intValue());//id
    int prodResult=pstmt2.executeUpdate();//
    pstmt3=conn.prepareStatement(sqlProd_channelDelStr);
    pstmt3.setInt(1,prodIDInt.intValue());
    pstmt3.executeUpdate();
    int channelResult=0;
    for(int i=0;i<prod.getChannelIDsInt().length;i++)
    pstmt4=conn.prepareStatement(sqlProd_channelInsertStr);
    pstmt4.setInt(1,prodIDInt.intValue());
    pstmt4.setInt(2,prod.getChannelIDsInt());
    pstmt4.addBatch();
    pstmt4.executeBatch();
    //((OraclePreparedStatement)pstmt).sendBatch(); // JDBC sends the queued request
    if((prodResult>0)&&(priceResult>0))
    successB=true;
    catch(Exception ex)
    successB=false;
    ex.printStackTrace();
    finally
    //closing the preparedstatement
    try
    if(pstmt1!=null)
    pstmt1.close();
    if(pstmt2!=null)
    pstmt2.close();
    if(pstmt3!=null)
    pstmt3.close();
    if(pstmt4!=null)
    pstmt4.close();
    catch (SQLException ex)
    ex.printStackTrace();
    return successB;

    Check this loop.
    or(int i=0;i<prod.getChannelIDsInt().length;i++)
    pstmt4=conn.prepareStatement(sqlProd_channelInsertStr);
    pstmt4.setInt(1,prodIDInt.intValue());
    pstmt4.setInt(2,prod.getChannelIDsInt());
    pstmt4.addBatch();
    Here every time the loop executes, a new statement object is created and assigned to the same statement object reference pstmt4. So finally when u r closing the stmt objects, only one stmt object gets closed out of prod.getChannelIDsInt().length that gets created with in the loop.

  • Maximum open cursors exceeded prblm , code attached for review

    I am getting the following exception in my code
    java.sql.SQLException: ORA-01000: maximum open cursors exceeded
    My code is as follows
         public ResultSet getFiles() throws Exception
              ResultSet rs = null;
              PreparedStatement pst = null;
              String fileqry = "select * from FILES_SENT where FILESTATUS= 'TOBS' ";
              pst = connection.prepareStatement(fileqry);
              try
                   rs = pst.executeQuery();
              catch(Exception e)
                   System.out.println("In getFiles" + e );
                   System.exit(0);
              return rs;          
         public void RUN()
              while(true)
                   try
                        System.out.println("opening cursor "  );
                        FileResultSet = getFiles(); // polling the DB for new messages
                        if (FileResultSet!= null && FileResultSet.next()) // if new files are found
                             do // for each of the records
                                  String Filename = FileResultSet.getString("FILENAME");
                                  System.out.println("Processing the file " + Filename);
                                  // getting the messagetype from the filename
                                  String MessageType= Filename.substring(0,1);
                                  String InternalMessageID = getInternalMessageID(MessageType);
                                  System.out.println("internalmessageid of the file " + InternalMessageID);
                             while (FileResultSet.next());
                             System.out.println("Processed all messages");
                        else
                             System.out.println("closing cursor "  );
                             FileResultSet.close();
                        Thread.sleep(10);
                   catch(Exception f)
                        System.out.println("exception in RUN " + f);
                        System.exit(0);     
         }The database is oracle 10g
    The loop is going for 300 times with out any data and then comes down with this exception.
    Experts please give your valuable help in this.
    Dinesh

    I had previously tried to close the statement
    immediately after the exceute statement , but the
    resultset is lost after that .
    So where shoud i close the statement ?Don't keep ResultSets around! See this whole thread:
    http://forum.java.sun.com/thread.jspa?threadID=788017
    You should:
    1. Open connection
    2.Open statement
    3.Get ResultSet
    4.Convert ResultSet into something better
    5. close ResultSet
    6.close statement
    7.close connection
    8. return the "something better you converted the ResultSet into"
    Of course 5,6,7 should be coded in a way they ALWAYS get executed regardless of any exception may occur (for example in finally block).
    1 to 8 may also be replaced by (unless your purpose is only to learn JDBC basics):
    1. use some kind of high level framework/library/standard (Hibernate,Ibatis,JPA if you use Java 1.5+... you name it, there are as much as you may need, or maybe even a few more!)
    Hope this helps,
    Riccardo

Maybe you are looking for

  • OS Package Error while installing SOA 11.1.1.5.0 on Linux

    Hi, I am trying to install SOA Suite 11.1.1.5.0 on Linux Environment. While doing the prerequisite checks, I am getting some errors wrt operating system packages and kernel parameters. The queries I have is: 1) If these packages are not installed, wi

  • Unable to display Tomcat default homepage

    When i am not connected to internet, i get the default Apache Tomcat homepage after successfully starting the Tomcat server. However, once i get my internet connections enabled, I am unable to get the default Apache Tomcat home page. I tried to chang

  • K8600 Print Quality

    Having a problem with a K8600 - the magenta cyan printhead works perfectly and then when it sites for a few minutes between uses I get thin white lines in the color printout - black letters are fine.  It sure looks like several of the jets are not fi

  • Duplication of a short section of track when burning a cd

    Has anyone had this problem when burning a cd? A short section from the start of the next track is included at the end of the previous track. It doesn't happen every time but more often than not. I have tried changing the gap between trcks and that d

  • Leopard Installation Nightmare - Mac Pro

    I have a Mac Pro running 10.4 with plain vanilla everything (hardware and software). I started an upgrade install with Leopard today (so excited!) only to have it abort when it was nearing completion of the DVD verification phase. When it rebooted, t