[Help] statement.executeQuery(query) opens MULTIPLE cursors

Hey everyone,
I'm having a real hard time finding anything about this on the net so I've turned here. When we call:
resultSet = statement.executeQuery(query)
from a servlet for some reason that one executeQuery opens anywhere from 9-12 cursors in our oracle DB. All the executeQuery documentation I could find just said it should open 1 cursor for that particular ResultSet. query is a fairly simple SQL statement, it searches multiple tables but that doesn't explain why it should open so many cursors.
On a side note the resultSet and statement are global to the method and are closed in the finally block, no SQLExceptions are thrown further adding to my confusion.
If anyone has seen something like this where executing 1 query opens multiple cursors please let me know any information you might have.
Thanks in advance
-Dave

Hi Dave
I had a similar problem using the Oracle 8i, but my query was a more complicated than yours and opened a lot of cursors.
The answer is to close every ResultSet and the Statement:
while (xxResult.next()){ ... }
xxResult.close();
xxResult.getStatement().close();
This worked for me,
Good luck,
Daniel.

Similar Messages

  • Get Stuck At stat.executeQuery(query) Function

    Hi,
    Can Any one Tell.
    What Can be The possible reasons For The executeQuery function get stucked?
    Table from where i am getting the value has only two row.
    and i am using mysql-connector-java-5.1.6-bin.jar driver to get connected to mysql.
    Some times the query works fine , but sometimes it get Stuck at this function , then i have to restart the mysql to work again properly.
    Thanks

    Ashutoshklkkkkkkkkkkkkkkk wrote:
    And the i don't close the connection i just kill the application .
    What can be the side effect of not closing the connection only just killing the application on linux.If you don't close a connection, it stays open until it times out in the DB side. Which may be one hour, but it can also be one day or more. The more unclosed connections you have, the lesser resources the database will have left and it will finally die.
    Always, I repeat, always close expensive resources explicitly. Do that in the finally block. Acquire and close Connection, (Prepared)Statement and ResultSet in the shortest possible scope.

  • Help with sql query for multiple years

    Hello,
    I am new to SQL and am trying to perform a query that includes multiple years from 2005 to 2011.
    I was trying to enter the following query but received a message that said "Operand should contain 1 column(s)"
    SELECT * FROM `auto_2` WHERE `year` LIKE (2005, 2006, 2007, 2008, 2009, 2010, 2011);
    What am I doing wrong here? Please advise...
    Thanks

    Hi and welcome to the forum,
    You cannot use LIKE here, that is for pattern matching.
    You need either IN operator, or less known =ANY.
    Regards
    Peter

  • Help with a query.. (multiplication / division)

    Hi All, i have this data example
    CREATE TABLE "TB_CONVERSION_UNIDAD_TMP"
      ("ID_PRODUCTO"    NUMBER,
        "FLG_OPERADOR"   CHAR(1 BYTE) NOT NULL ENABLE,
        "NUM_FACTOR"     NUMBER(10,6) NOT NULL ENABLE);
    Insert into TB_CONVERSION_UNIDAD_TMP (ID_PRODUCTO,FLG_OPERADOR,NUM_FACTOR) values (null,'M','0,0001');
    Insert into TB_CONVERSION_UNIDAD_TMP (ID_PRODUCTO,FLG_OPERADOR,NUM_FACTOR) values (null,'D','1');
    Insert into TB_CONVERSION_UNIDAD_TMP (ID_PRODUCTO,FLG_OPERADOR,NUM_FACTOR) values (null,'M','1');
    Insert into TB_CONVERSION_UNIDAD_TMP (ID_PRODUCTO,FLG_OPERADOR,NUM_FACTOR) values (null,'M','2');
    Insert into TB_CONVERSION_UNIDAD_TMP (ID_PRODUCTO,FLG_OPERADOR,NUM_FACTOR) values ('79','M','1');
    Insert into TB_CONVERSION_UNIDAD_TMP (ID_PRODUCTO,FLG_OPERADOR,NUM_FACTOR) values ('17','M','100');
    Insert into TB_CONVERSION_UNIDAD_TMP (ID_PRODUCTO,FLG_OPERADOR,NUM_FACTOR) values ('16','M','10');
    Insert into TB_CONVERSION_UNIDAD_TMP (ID_PRODUCTO,FLG_OPERADOR,NUM_FACTOR) values ('16','M','1');
    Insert into TB_CONVERSION_UNIDAD_TMP (ID_PRODUCTO,FLG_OPERADOR,NUM_FACTOR) values ('78','D','48');
    Insert into TB_CONVERSION_UNIDAD_TMP (ID_PRODUCTO,FLG_OPERADOR,NUM_FACTOR) values ('18','D','100');
    Insert into TB_CONVERSION_UNIDAD_TMP (ID_PRODUCTO,FLG_OPERADOR,NUM_FACTOR) values (null,'M','1');
    Insert into TB_CONVERSION_UNIDAD_TMP (ID_PRODUCTO,FLG_OPERADOR,NUM_FACTOR) values (null,'M','11');
    Insert into TB_CONVERSION_UNIDAD_TMP (ID_PRODUCTO,FLG_OPERADOR,NUM_FACTOR) values (null,'M','1111');
    Insert into TB_CONVERSION_UNIDAD_TMP (ID_PRODUCTO,FLG_OPERADOR,NUM_FACTOR) values ('126','D','1111,19');
    Insert into TB_CONVERSION_UNIDAD_TMP (ID_PRODUCTO,FLG_OPERADOR,NUM_FACTOR) values ('40','D','2');
    COMMIT;
    /I want get the num_factor columns where's the condition i send is id_producto then validate if the column FLG_OPERADOR is 'M' or 'D' for the multiplication or division with the another parameter i send (val).
    so far i got this:
    set serveroutput on;
    DECLARE
    intFactor number(8,2);
    intID_Producto NUMBER(10):=126;
    strFlg_Operador CHAR(1);
    Cant number(8,2);
    Val number(8,2):=100;
    BEGIN
    select num_factor into intFactor from TB_CONVERSION_UNIDAD_TMP where id_producto=intid_producto and rownum=1;
    select flg_operador into strFlg_Operador from TB_CONVERSION_UNIDAD_TMP where id_producto=intid_producto and rownum=1;
    if (strFlg_operador='M') then
        Cant:=Val*intFactor;
    else
        Cant:=Val/intFactor;
    end if;
    dbms_output.put_line('Factor :' || to_char(intFactor) || ' Operador ' || strFlg_Operador || ' Total : ' || to_char(Cant));
    END;Thanks for the help.

    Wrong forum!
    This is the sql developer forum and is not for sql or pl/sql questions.
    Please mark this question ANSWERED and if the below doesn't answer your question repost the question in the sql and pl/sql forum.
    >
    I want get the num_factor columns where's the condition i send is id_producto then validate if the column FLG_OPERADOR is 'M' or 'D' for the multiplication or division with the another parameter i send (val).
    >
    You've got a good start. Now you just need to BULK COLLECT the data and loop thru it. By the way you don't need two separate queries.
    set serveroutput on;
    DECLARE
    intFactor number(8,2);
    intID_Producto NUMBER(10):=126;
    strFlg_Operador CHAR(1);
    Cant number(8,2);
    Val number(8,2):=100;
    type tbl_factor is table of number(8,2);
    type tbl_flg is table of char(1);
    t_factor tbl_factor;
    t_flg tbl_flg;
    intID1 NUMBER(10):=40;
    BEGIN
    select num_factor into intFactor from TB_CONVERSION_UNIDAD_TMP where id_producto=intid_producto and rownum=1;
    select flg_operador into strFlg_Operador from TB_CONVERSION_UNIDAD_TMP where id_producto=intid_producto and rownum=1;
    if (strFlg_operador='M') then
        Cant:=Val*intFactor;
    else
        Cant:=Val/intFactor;
    end if;
    dbms_output.put_line('Factor :' || to_char(intFactor) || ' Operador ' || strFlg_Operador || ' Total : ' || to_char(Cant));
    select num_factor, flg_operador bulk collect into t_factor, t_flg
    from TB_CONVERSION_UNIDAD_TMP where id_producto=intid1;
    for i in 1..t_factor.count loop
       if (t_flg(i)='M') then
           Cant:=Val*t_factor(i);
       else
           Cant:=Val/t_factor(i);
       end if;
      dbms_output.put_line('Factor :' || to_char(t_factor(i)) ||
      ' Operador ' || t_flg(i) || ' Total : ' || to_char(Cant));
    end loop;
    END;
    /

  • Photoshop is opening multiple times...WHY??? (please help).

    When I double click on an image (from Bridge for example) to open in Photoshop it will open up CS6 and then sometimes when I open another image, instead of opening up in the same open Photoshop program, it will open up an additional Photoshop program.  Both CS6, Version 13.0.6 x64.  Super frustrating when sitting with a client and trying to add an image to a document and it opens up in a different program...   Is there a way to see where Photoshop is opening from?  Why would CS6 be opening multiple times???
    I don't think I noticed this happening before I upgraded to Mavericks (yes, this has been happening for a while).  I also have a back-up program called SuperDuper that mirrors my system on a separate hard drive.  Could Photoshop be opening from there, too?
    Thanks for any possible help!
    Deron

    Use Lion Recovery to reinstall the Mac OS X.

  • WHY does Firefox repeatedly open multiple copies of tabs that are already open??? Yesterday I cleared the history, removed the program & reinstalled. Didn't help. Some tabs are ones I had months ago but don't need now. They keep appearing. HELP, please!

    The problem started several months ago, after I downloaded a new version of the program. Two updates ago, I think. The repeat tabs open multiple times during the day. Sometimes they appear hours after I've closed them--sometimes just minutes later.

    It is possible that there is a problem with the files sessionstore.js and sessionstore.bak in the Firefox Profile Folder.
    Delete the files sessionstore.js [2] and sessionstore.bak in the Firefox Profile Folder.
    * Help > Troubleshooting Information > Profile Directory: Open Containing Folder
    * http://kb.mozillazine.org/Profile_folder_-_Firefox
    If you see files sessionstore-##.js with a number in the left part of the name like sessionstore-1.js then delete those as well.<br />
    Deleting sessionstore.js will cause App Tabs and Tab Groups and open and closed (undo) tabs to get lost, so you will have to create them again (make a note or bookmark them).
    See also:
    * [1] http://kb.mozillazine.org/Session_Restore
    * [2] http://kb.mozillazine.org/sessionstore.js

  • Open multiple forms, few in Enter-Query mode

    Hi All,
    I want to open multiple forms from a form using open_form built-in. If user clicks on different items of the parent form different child forms are invoked.
    But if one child form is opened in Enter-Query mode (I have 'enter_query;' in its when-new-form-instance) it does not allow to put focus back on parent form and invoke other forms until I execute_query in child form or close the child form.
    Waiting for your replies. Thanks in advance.
    Regards
    Mona

    Hi Friends,
    Has anybody ever faced this problem. Please reply.
    Regards

  • I have Mac OSX maxmini; Safari states "can't open server since starting with 'open-help-anchor'.  How do I get into the web site this is blocking?

    I have Mac Mini OSX 10.6.2; Safari states "can't open server since url starting with 'open-help-anchor'.  I didn't type this but possibly I was hijacked but it only occurs on the specific banking site I'm trying to get into.  How do I get into the web site I've always been able to get but now this is blocking it?   Is this related to cookies?

    https://discussions.apple.com/message/25085868#25085868
    I started a thread in safari maverics, I ment to put it in iOS Safari.  New Thread lists all the steps I've taken.  No I haven't tried another browser.  I've only ever used Safari on my iDevices.

  • How can I open a cursor for dynamic sql statement

    Hi,
    I'm facing issues opening a cursor for dynamic sql statement : PLS-00455: cursor 'RESULT1' cannot be used in dynamic SQL OPEN statement.
    CREATE OR REPLACE FUNCTION DEMO
    (MN_I in VARCHAR)
    return AB_OWNER.ABC_Type.NonCurTyp is
    RESULT1 AB_OWNER.ABC_Type.NonCurTyp;
    sql_stmt VARCHAR2(4000);
    BEGIN
    sql_stmt := 'SELECT * FROM AB_OWNER.DUN WHERE JZ_I in ('||mn_i||') ORDER BY app.ACC_I';
    OPEN RESULT1 FOR sql_stmt;
    END IF;
    return RESULT1;
    END DEMO;
    What changes should I make in the code so that it doesn't fail? I can't change the definition of RESULT1 cursor though.

    Gangadhar Reddy wrote:
    I used SYS REFCURSOR and was able to implement successfully.How many times did you run this successful implementation that does not use bind variables?
    Because this is what will happen when it runs a lot.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17766/e2100.htm#sthref1874
    http://forums.oracle.com/forums/search.jspa?q=%2BORA-04031%20%2Bbind&objID=c84&dateRange=all&rankBy=10001&start=30
    And you will have to regularly restart the server, or possibly slightly less invasive, flush the shared pool.
    Flushing Shared Pool regularly
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1516005546092
    >
    Ok, this is an easy one to diagnose.
    You are not using bind variables. This is terrible. Flushing the shared pool is a bad
    solution -- you are literally killing the performance on your box by not using them.
    If I was to write a book on how to build “non scalable applications in Oracle”, this
    would be the first and last chapter. This is a major cause of performance issues and a
    major inhibitor of scalability in Oracle. The way the Oracle shared pool (a very
    important shared memory data structure) operates is predicated on developers using bind
    variables. If you want to make Oracle run slowly, even grind to a total halt – just
    refuse to use them.
    >
    But, please feel free to go ahead with this successful implementation.
    I just hope anyone else who reads this doesn't make the same mistake.

  • Need help with select statement or query

    Not familiar with what to call it, but here is what i need...
    To give our analyst a better idea of warranty on some of our
    equipment, i
    would like to add to the page a column that displays if the
    device is still
    under warranty
    I currently capture the date the equipment was returned from
    repair, so what
    could i use within my select statement or query to display a
    warranty
    expiration date or display on the page...
    example :
    Returned from repair 10/20/2006 warranty expires on
    11/20/2006
    each equipment has different warranties, so i need a formula
    or something to
    say... device #1 has 60 day warranty ( so 10/20/2006 + 60days
    =
    12/19/2006 )
    I would imagine this to be a query
    Table 1 would contain the equipment type and warranty time
    Table 2 would contain the current status of the equipment
    Query would take the back from repair date + warranty =
    expiration date

    Simple. Join the two tables and create a derived column for
    the expiration date. The exact syntax is dependant on your DBMS, so
    check the manual for whichever you are using and look at the date
    functions. There will be a function that will allow you to add a
    number of date units (day, month, year, etc) to a date
    field.

  • Single jdbc connection opens multiple connections to sql server

    Hello!
    I'm having a bad problem, because one jdbc connection opens multiple connections to the sql server. I'm working with the open source jdbc driver jtds and the ms sql server. Because I'm using temporary tables that are only visible to one database connection, my code doesn't work. Is this a bug in jtds or is this the normal behaviour of a java.sql.Connection?
    Here a code example:
    Class.forName("net.sourceforge.jtds.jdbc.Driver");
    conn = DriverManager.getConnection(
    "jdbc:jtds:sqlserver://"+dbConnDef.getServer()+"/"+dbConnDef.getDatabase(),
    dbConnDef.getUserName(),
    dbConnDef.getUserPasswd()
    Statement stmt = conn.createStatement();
    stmt.executeUpdate("SET DATEFORMAT YMD");
    stmt.close();
    stmt = conn.createStatement();
    stmt.executeUpdate("CREATE TABLE #tmp (FieldA INT NOT NULL)");
    stmt.close();
    stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT * FROM #tmp");
    stmt = conn.createStatement("SELECT FieldA AS sthElse FROM #tmp");
    ResultSet rs2 = stmt.executeQuery("SELECT * FROM #tmp");
    // the strange thing is, that this second query does NOT yet open a
    // new connection, but the next sql command does.
    stmt = conn.createStatement();
    stmt.executeUpdate("DROP TABLE #tmp");
    stmt.close();
    Why is it behaving that strange way? It is absolutely necessary, that EVERYTHING that I do with my connection is really done on the same connection to the SQL server! How can I force a java.sql.Connection not to open multiple sql-server-connections?
    It is very urgent, thus, PLEASE HELP!!!
    Thousand thanks in advance! Marco.

    ...but that means, that the jdbc driver I use, is not working properly, because it should work the following way (please correct me, if I misunderstood the concept):
    I create a Connection object which should represent exactly one physical connection to the database. Then I can create as many Statement instances by conn.createStatement() as I want. There should still exist only one physical connection.
    With each of my Statement objects, I can create one result set.
    This means, I should be able to create as many result sets as I want to with only one Connection object (and therefor one physical connection) by creating multiple Statements, right?!
    If this is correct, the concept is perfect for me and exactly as I'm used to it by other programming languages. Then, only my jdbc driver does not work properly which means I either have to replace it by another one or change it myself (it's open source).

  • Effect of Multiple cursors in Function Module Extractors

    Hi,
    I am trying to use multiple cursors in an FM extractor, like this:
    OPEN CURSOR WITH HOLD c1 FOR <select query 1>.
    OPEN CURSOR WITH HOLD c2 FOR <select query 2>.
    FETCH NEXT CURSOR c1
                   INTO CORRESPONDING FIELDS
                   OF TABLE i_equi.
    FETCH NEXT CURSOR c2
                   APPENDING CORRESPONDING FIELDS
                   OF TABLE i_equi.
    " Further processing of equipments
    " obtained in i_equi
    I am also checking SY-SUBRC, after each Fetch statement. If both cursors happen to be empty, the extractor exits by raising no_more_data, like other extractors.
    It is possible to do so, since I just tried it. The question is, are there any disadvantages of this kind of approach in terms of memory or speed?
    Edited by: Suhas Karnik on Sep 29, 2008 12:06 PM

    hI kiran,
    The simple way is to create a data element & domain with value range where u provide set of fixed values or provide a check table to it.
    Use that data element in a table <ztable>.
    Code:
    Parameters:
          p_burks like <ztable>-dataelement.
    Call Function <function_name>
    exporting
    p_burks = p_burks,

  • Open ref cursor in a procedure

    Hi
    I have a procedure which has 3 input parameters and 1 REF CURSOR type OUT parameter.
      In the body of the procedure a select query is dynamically being created, and just before the end of the procedure the REF CURSOR is opened for SELECT(dynamic) query
    For Ex: Create or replace procedure proc_name(a in number,b in number,c in number,RETVAL OUT REF CURSOR) as
    decalre
      strQry varchar2(3000);
    begin
       -- strQry is select query built dynamically
    OPEN RETVAL for strQry;
    end proc_name;
    This procedure is being called by a java application. My question is what the open cursor statement is doing in the procedure?
    Any ideas? Thanks!
    greddy

    Hi,
    As i know, for example if we want to generate a report for some particular records in our project.consider we are using java as front end and oracle as backend. ok. In that case we need to bring the data from backend to front end ,for that in backend (oracle) we can write procedure to perform this task using ref cursors.
    Note: ref cursor will provide the most efficient way in bringing the records from back end to front end.
    Create or replace procedure proc_name(a in number,b in number,c in number,RETVAL OUT REF CURSOR) as
    decalre
    strQry varchar2(3000);
    begin
    -- strQry is select query built dynamically
    --if we are using dynamic query, we can filter out the records using id or name or date
    once we did, we need to pass the values to calling enviroment, since we declared the ref cursor as out parameter, we can use the ref cursor to pass the values to calling enviroment. Since we are using ref cursor we need to open the cursor for that dynamic query.
    OPEN RETVAL for strQry;
    end proc_name;
    hope this information is some what helpful. if you got any details regarding this please post it..
    thanks.

  • Mouse freezes when opening multiple windows

    With web browser open and several other windows, mouse seems to freeze with random jerky movements.  I can eventually drag the cursor up to the Apple logo to restart system.

    Dear all,
    I think I have the same problem... or not ?!
    => When I try to open multiple files at the same time it opens only the 2 or 3 first ones then it freezes on the Spinning Beach Ball of Death !
    => Then it never completely finishes loading and freezes up Indesign.
    => I am unable to cancel the dialog box and have to use cmd+alt+esc to close the program
    => then, the files open directly on indesign when I open the program again (jus as if the files had been loaded and ready to go)
    I am working on MAC OS X (10.7.3)
    Anybody could help please ?? (sorry for my english... I'm a French native speaker) 

  • Help - JDBC MS SQL Server and Cursors Error

    Hello,
    Please help. I am using weblogic 8.1 and MS SQL Server 2000. Using JDBC. I have am calling a stored procedure which outputs a CURSOR. I haveing problems specifying the right java.sql.Type for this. I tried java.sql.Type.OTHER but it fails. The code is as follows
    Connection conn = null;
    CallableStatement stmt = null;
    String sqlProc = "{ call GetDocumentDetails(?,?) }";
    try {
    conn = this.getConnection();               
    stmt = conn.prepareCall(sqlProc);
    stmt.setInt(1, docId);
    stmt.registerOutParameter(2,Types.OTHER);
    stmt.execute();
    ResultSet rs = (ResultSet) stmt.getObject(2);
    while(rs.next()) {
    The exception that I get is
    java.sql.SQLException: [BEA][SQLServer JDBC Driver]The specified SQL type is not supported by this driver.
         at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
    PLEASE HELP.
    Thanks in advance
    GM

    hi llturro,
    Thanks for answering my question. I have tried out what you suggested, but I still can't fix my problem. The following are the messages that display when I try to run my servlet. It seems that the DataSource, Connection and Statement are ok, however when it comes to the ResultSet the error message appear. What's wrong with my ResultSet coding ?
    ResultSet rs = stat.executeQuery("SELECT ISBN FROM BOOKSINFO WHERE ISBN='"+primarykey+"'");
    setEntityContext Method
    Find by primary key
    DataSource OK
    Connection OK
    Primary Key = 013-00-675721-9
    Statement OK
    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
    java.rmi.RemoteException: Unknown Exception/Error thrown by EJB method.; nested exception is:
    java.lang.NullPointerException
    java.rmi.RemoteException: Unknown Exception/Error thrown by EJB method.; nested exception is:
    java.lang.NullPointerException
    java.lang.NullPointerException
    <<no stack trace available>>

Maybe you are looking for