To Joe Schell - jschell... - PreparedStatement and executeBatch()

Hi,
Thanks for the reply to the PreparedStatement and executeBatch() query. Is there any workaround for it other than using the Statement object?
thanks,
Nish

Could be.
But since I have no idea about what you are talking about, I can't really comment.
I respond to between 10-30 threads a day and read more than that. Consequently I need a context to understand questions.
If I have previously (recently) responded to a previous thread then if you post a response to it I will generally see it in less than a day. If is an older thread you might want to start a new thread. But if you do then add a link or put enough content so I can follow it.

Similar Messages

  • PreparedStatement and executeBatch()

    Hi,
    I am trying to insert records into the database using the addBatch() and executeBatch() methods. I am using PreparedStatement. And I am trying to insert 52 records at a time.
    I have the records in an array, and I am looping through the array, setting the parameters for the prepared statement and doing addBatch(). And finally when I come out of the loop I call preparedStatement.executeBatch().
    int[] updateCounts = ps.executeBatch();
    Here it is throwing out the ArrayIndexOutOfBoundsException. Anybody has any idea why this is happening? This works fine with the Statement object, but it is with the PreparedStatement that I am having this problem. I am using JDK 1.3. My database is DB2 UDB 7.1 and my driver is IBM DB2 ODBC Driver.
    thanks in advance,
    Nish

    Hi,
    Thanks for the reply... Here is my code.
    public void insertNetFcst(Connection con, PreparedStatement ps, NetForecast[] arrNF){
    Connection conn = con;
    PreparedStatement psIns = ps;
    NetForecast[] arrNet = new NetForecast[52]; //Array of objects of type NetForecast
    arrNet = arrNF;
    int intLen = 0;
    intLen = arrNet.length;
    try{                    
    for (int ins = 0; ins < intLen; ins++){
    NetForecast nFct = new NetForecast();
    nFct = (NetForecast)arrNet[ins];
    psIns.setString(1, nFct.getCorpId());
    psIns.setString(2, nFct.getDivId());
    psIns.setString(3, nFct.getShipWhseId());
    psIns.setString(4, nFct.getRecvWhseId());
    psIns.setDouble(5, nFct.getUpcId());
    psIns.setInt(6, nFct.getYearId());
    psIns.setInt(7, nFct.getWeekNbr());
    psIns.setInt(8, nFct.getDemandQty());
    psIns.setString(9, nFct.getUomCode());
    psIns.setInt(10, nFct.getReqdYear());
    psIns.setInt(11, nFct.getReqdWeek());
    psIns.setString(12, nFct.getFcstTypeInd());
    psIns.setTimestamp(13, new Timestamp(System.currentTimeMillis()));
    psIns.addBatch();
    int[] updateCounts = psIns.executeBatch();
    //I am getting the exception at this line... where I call executeBatch()
    conn.commit();
    catch(BatchUpdateException b){
    System.err.println("SQLException: " + b.getMessage());
    System.err.println("SQLState: " + b.getSQLState());
    System.err.println("Message: " + b.getMessage());
    System.err.println("Vendor: " + b.getErrorCode());
    System.err.print("Update counts: ");
    int [] updateCounts = b.getUpdateCounts();
    for (int i = 0; i < updateCounts.length; i++) {
    System.err.print(updateCounts[i] + " ");
    b.printStackTrace();
    catch(SQLException insExp){
    System.out.println("Duplicate record exception..." + insExp);
    thanks,
    Nish

  • PreparedStatement or executeBatch

    I have a text file which has more than 100,000 rows. I have to read it line by line and updates some tables accordingly. My question is which one will give me best performance: PreparedStatement or executeBatch?
    Thanks

    Your question is strange.
    Use PreparedStatement AND executeBatch().
    But make sure to execute the batch every 1000 rows or so, if you try to do all the 100.000 rows in one go you might get problems.

  • PreparedStatement and batchExecute

    Hi,
    I am trying to use PreparedStatement and batchExecution for inserting a few rows into database. I am using JTurbo driver.
    But it only inserts the last set of values. For Example
    Class.forName( "com.ashna.jturbo.driver.Driver" );
    Connection con = DriverManager.getConnection( "jdbc:JTurbo://server","username","password" );
    PreparedStatement pstm = con.prepareStatement( "INSERT INTO Test( ids, age, wt ) VALUES(?,?,?)" );
    int ids[] = {1000,1001,1002,1003};
    String[] age = { "12","13","14","15" };
    String[] wt = { "45","46","47","48" };
    for( int i=0 ; i<ids.length ; i++ )
    pstm.setInt( 1, ids[i] );     
    pstm.setString( 2, age[i] );
    pstm.setString( 3, wt[i] );     
    pstm.addBatch();
    int[] rows = pstm.executeBatch();
    pstm.clearBatch();
    con.close();
    In database, it shows
    1003, 15, 48
    1003, 15, 48
    1003, 15, 48
    1003, 15, 48
    Pls..pls..help me with this...i'm having a hard time figuring out this problem.. :(
    Thanks a lot...

    Maybe you just wrote this short-hand but if not try this:
    pstm.setInt( 1, ids[i] );
    pstm.setString( 2, age[i] );
    pstm.setString( 3, wt[i] );
    //...........

  • What's the difference between "PreparedStatement" and "Statement"?

    What's the difference between "PreparedStatement" and "Statement"?
    Which is better??????

    Read the docs for the two classes. The differences are apparent there.
    Which one is better depends on your needs. I think that constructing and executing a PreparedStatement can be a bit less performant than just a Statement, if you're only executing the query one time. But I don't think that difference will normally be noticable in the context of a given application.
    Additionally, if you have to pass any dates or strings to the query, you'll want PreparedStatement's parameters, rather than trying to format and escape things in the query string.

  • Using PreparedStatement and the Oracle Error ORA-1000

    Hi,
    I have a question about PreparedStatement objects that is not so simple to explain for me. What I would like to know is: if I use a PreparedStatement following traditional and generic steps:
    1- PreparedStatement pStmt = Connection.prepareStatement(sQuery);
    2- pStmt.setXXX(i,j);
    n - pStmt.setXXX(i,j);
    n+1 - ResultSet rs = pStmt.executeQuery();
    n+2 - while(rs.next()){ ... retrive ResultSet data  ... }
    n+3 - rs.close()
    n+4 - back to point number 2
    and at the end (as you can see in the point numbered n+4), instead of closing the PreparedStatement pStmt using the close() method, I reuse the PreparedStatement pStmt comeing back to the point numebr 2 and setting again all its parameters with new values ... then ... what heppens in the Oracle database ? Has been the cursor (so the mamory area), associated to my PreparedStatement object pStmt, duplicated or is it the same ?
    I know that Java allows you to do this kind of operations with PreparedStatement, and I know that in tha Java Documentation is explained to follow this strategy to optimize the execution time because in this way the same PreparedStatement is precompiled and prepared only once. But if I do a for loop following the steps explained before, after many iterations I have the error "ORA-1000: maximum open cursors exceeded". This error is the reason of my question. Does this error means that it's mandatory to close a PreparedStatement always, otherwise if you reuse it without closing it then the corresponding database cursor will be duplicated ? If it is so, then I think this is a contradiction with official java documentation ...
    I'm using Oracle8i (version 8.1.7) and Oracle JDBC Thin Driver (Windows NT) for use with JDK 1.2.x. Moreover, in my database istance the parameter "maximum open cursor" is equal to 800 ...
    Thank you very much for suggestions :-)

    There is no need to close a prepared statement or its resultset for every iteration.
    After the first iteration in a loop, all subsequent executions of it will close the previous resultset. By adding close() method, you are making one extra costly call to the DB for no reason.
    Following is the sample code.I know what you are saying. In fact at the beginning I wrote my code in the same way of your sample (see the code of my first post at the begin of this page).
    But doing so, after thousand iterations of the loop, I had "Oracle Error ORA-1000 : maximun open cursor exeeded" even if in my database istance the parameter "maximum open cursor" is equal to 8000.
    At this moment in my code, for each iteration, I close the PreparedStatement and in this way I don't have anymore the error :-((
    So it seems that only in theory we can reuse a preparedStatement without closing it. In fact if we see the oracle system table "$open_cursor" (as Konrad Pietzka suggest me) we can find that, for each interation,
    at our line code "rs = pstmt.executeQuery();" correspond a new cursor in the database: this means that for each method "pstmt.executeQuery()" the database open a new cursor and do not use the previous one as it should.
    I posted a question two months ago to search if someone had the same problem (it seems that Konrad Pietzka had the same situation) and was able to explain me what is the cause.
    The only reason I found by myself for this problem, is that probably the Oracle JDBC Thin Driver for Windows NT/2000 has some bugs... but I'm not sure ...
    Thank you very much for you time !!
    bye :-))
    Fidalma

  • PreparedStatement and "in" clause

    I am trying to pass an "in" clause to a SQL statement as a bind variable, but keep getting an "invalid number" runtime error:
    The "where" clause of the SQL statement is:
    String wherestmnt = "where sh.header_id in ? ";
    I am using a PreparedStatement and am setting the bind variable as follows:
    pstmt.setString(1,"(34552)")
    If I change the "in" clause to "=" and do a set as pstmt.setString(1,"34552") it works fine.
    Any advice?
    null

    There is also another error. If you need to use the in clause the values must be within paranthesis,
    So if your query were like,
    select * from emp where empno in (?)
    then the bind would work. You can have as many ? as you want separated by commas and you can bind that many values..!

  • PreparedStatement and bind variable

    We are experiencing some werid performance break downs where database server looks healthy and our java applications are down to their knees.
    I was wondering if someone could help me clarify the comparison between PreparedStatement and bind variable. When I execute a PreparedStatement in java through the JDBC thin driver, would the database consider it a dynamic SQL or is it a SQL using bind variable? If this same statement is executed 100000 times, is it parsed 100000 times? We are using JDK131. How does it work?
    Is there any memory leak in PreparedStatement implementation in JDBC thin driver? Is there any known symptom to this problem? What is the recommended solution?
    Thank you very much!

    If PreparedStatement is parsed and cached, why is there setting to set implicit statement caching and explicit statement caching? Our DBA insists that it is parsed every single time. How would I find out for sure?
    The SQLs have not been changed. This sudden performance degradation started when a new client went live and we experienced higher than usual volumn. We are connecting using JDBC thin client from weblogic server to Oracle 8.1.7. It's been happening everyday since the client went live and the only way to get the performance back is to shutdown and restart the database server.
    I tried to search JDBC related issues. The only complain that I've found so far is that there may be some potential memory leak for a PreparedStatement. However, I have not found anything from Oracle's website that concurs to that.
    What is my best bet?

  • Database Procedure Calling by Using PreparedStatement and CallableStatement

    Hi
    We can execute Database Stored Procedure by using PreparedStatement and CallableStatement as well.Then what is the significance of having CallableStatement.
    Please let me know the difference between these two Statement objects particularly in Stored Procedures Execution.
    Thanks in advance
    Basha007

    A callable statement excecutes a stored procedure that's stored and run on the database server.
    A prepared statement doesn't require a database stored procedure. It's parsed and cached by the JDBC driver, and allows you to specify parameters and bind values to them at runtime. Those are usually used in loop constructs where you want to repeatedly execute the same SQL with different values.
    Not all RDBMS support stored procedures (e.g., MySQL), but every driver I've used allows PreparedStatements. - MOD

  • Suggestion regarding running preparedstatement and batchupdate

    I have to insert many rows in database therefore i use preparedstatement and for loop.I want to know if i add all the query in batch and then execute will it give better performance .Will sql statement is still in compiled form when execute in batch .Let if i add another sql statement which is different from previous sql statement in batch what the effect it has on performance.
    Thanks

    hi.,
    check this out..
    http://forum.java.sun.com/thread.jspa?threadID=154870&start=15&tstart=0

  • PreparedStatements and LIKE clauses

    Hi,
    I've come across a slight problem with PreparedStatements and LIKE clauses. Say I want my query to look something like this:
    SELECT * FROM CONTENT_TABLE WHERE CONTENT LIKE '%test%'If I were to use a PreparedStatement I'd do something like this:
    PreparedStatement searchContent = con.prepareStatement("SELECT * FROM CONTENT_TABLE WHERE CONTENT LIKE ?");
    searchContent.setString(1, queryString);This isn't correct becuase it matches where CONTENT LIKE 'queryString'
    I tried this:
    PreparedStatement searchContent = con.prepareStatement("SELECT * FROM CONTENT_TABLE WHERE CONTENT LIKE '%?%'");
    searchContent.setString(1, queryString);But I get a syntax error in my SQL.
    Is there another way around this?
    Thanks

    just guessing try this:
    PreparedStatement searchContent = con.prepareStatement("SELECT * FROM CONTENT_TABLE WHERE CONTENT LIKE '%?%'");searchContent.setString(1, "%"+queryString+"%");
    This might work, since ? gets replaced by '...', so i am guessing %..% will fit..
    give it a shot, i might be wrong.

  • PreparedStatement and Statement

    Hi Joe,
    We are using the Driver provided by Weblogic (jdriver) and not the one from
    Informix.Do you suggest any settings for this
    thanks
    Nirmala.

    Nirmala,
    Which version of Weblogic do you use?
    Regards,
    Slava Imeshev
    "Nirmala" <[email protected]> wrote in message
    news:3bcc9ff7$[email protected]..
    >
    Hi
    public void ejbLoad () throws RemoteException, NoSuchEntityException {
    Connection connection = null;//JDBC Connection from the pool
    PreparedStatement ps = null; // SQL query statement
    Statement statement = null;
    ResultSet rs = null; // JDBC result set
    try {
    // Obtain a connection from the connection pool.
    ID = (String) context.getPrimaryKey ();
    connection = DatabaseHelper.getConnection ();
    // Our SQL query.
    // Make sure to upshift the user id.
    String sqlQuery =
    "SELECT * from customer WHERE id= ?";
    long startTime = System.currentTimeMillis();
    ps = connection.prepareStatement(sqlQuery);
    ps.setString(1,ID.toUpperCase());
    // Read the customer data from the database.
    rs = ps.executeQuery ();
    long endTime = System.currentTimeMillis();
    long total = endTime -startTime;
    System.out.println("total time taken1 " +CISSLogger.getTimeInSeconds(total));
    >
    >
    // rs = ps.getResultSet();
    Above is the snippet of the code we are using in ejbLoad,
    Appreciate your suggestion
    thanks
    Nirmala.
    "Slava Imeshev" <[email protected]> wrote:
    Hi Nirmala,
    Could you give us a fragment of your code that uses PreparedStatement?
    Regards,
    Slava Imeshev
    "Nirmala" <[email protected]> wrote in message
    news:3bcc8772$[email protected]..
    Hi Joe,
    We are using the Driver provided by Weblogic (jdriver) and not theone
    from
    Informix.Do you suggest any settings for this
    thanks
    Nirmala.

  • Reuse of preparedstatements and the connection pool

    It seems useful (for performance reasons) to reuse a prepared statement in
    subsequent calls to the database. In WebLogic, however, after each call we
    return the Connection object to the WebLogic connection pool. A prepared
    statement is created on a specific Connection object. The next time we want
    to use the same query we get a Connection from the pool, which might be
    another instance of the Connection class. Therefor it seems impossible or at
    least dangerous to reuse the same prepared statement. Even in the case this
    would work we're indirectly using the other Connection, which we already
    returned to the pool and which could be retrieved from the pool by someone
    else. So, can't we reuse preparedstatements ?

    Hi Raja,
    Currently the only bullet-proof way to make sure that all statements are
    cached is to set the cache size to a number of possible prepared statements
    in the application.
    The only consequence of increased cache size is growing amount of
    memory required by a server instance.
    Regards,
    Slava Imeshev
    "Rajiv Jauhari" <[email protected]> wrote in message
    news:[email protected]...
    Is there an easy way to tell whether the prepared statement cache size one
    has set is
    appropriate? Some way to monitor cache hit rate or usage count (i.e., the
    actual number of statements cached) while running a load test? I'm using
    Weblogic 6.1sp3 and Oracle 8.1.7.4.
    Another way to think of this question is: is there a negative impact ifthe
    cache size is set too large?
    In the case of Oracle I believe one might run out of cursors, but is there
    any other negative consequence that you know of?
    Thanks,
    Rajiv
    "Joseph Weinstein" <[email protected]> wrote in message
    news:[email protected]...
    Vyas wrote:
    If multiples (of the same statement) can be cached would it not result
    in too many
    prepared statements of the same type in the cache ?
    This could happen
    1. When a load test is done when all the threads start doing exactly
    the
    same work.
    Because of contention everybody gets their own statement copy(theoritically, even
    if in practice it may not exactly happen like that). In such a case
    you
    are going
    to create load on the database in terms of open cursors.Each thread will get it's own connection, and the statement cache isper-connection.
    Cursors, in Oracle's case, do need to be configured to support acache-full of
    retained statements. Alternately, the cache should be set to a smallenough size to
    require only as many cursors as the DBMS will allow per connection.
    Another issue is what happens when the cache limit is hit ?
    In the above example let's say cache limit is 50 and I am doing 50
    user
    load test.
    because of load test let's say the cache gets filled with 50 of the
    same
    statement.
    When load test moves to the next sequence of action requiring a
    diffrent
    statement
    what happens to the cache ?
    thanks
    VyasThe only way a given connection's statement cache will get a duplicatestatement
    is if some single JDBC thread required multiple copies of the samestatement. A
    multi-user test will usually just ensure that each pooled connectioncaches the
    same selection of different statements that the test user used. If thetest user
    just repeatedly makes and uses one statement, the first time they do it,the
    statement will be cached, and every subsequent repeat of the user codewill get
    the same cached statement. The cache will still have 49 empty slotswaiting for
    different statements. Currently the cache is simple-minded. It is a
    fixed
    (configurable)
    size per connection, and the first N prepared/callable statements getcached for the
    life of the pooled connection that created them. All other subsequentstatements will
    be made and closed on a per-connection-use basis. Therefore, it can bethat a startup
    or stress load that runs before standard runtime service, and which usessignificantly
    different a statement profile could populate the cache with rarely-usedwasted statements.
    If I were a customer in this circumstance, I would either prime thecaches, by determining
    which statements I wanted cached, and then running a startup class thatreserved all the
    pool connections, and made these statements on each before closing them.Alternately,
    after startup/stress I would reset the pool, and allow the runtime load
    to
    fill the cache of
    the regenerated pool.
    Joe Weinstein at B.E.A.
    thanks
    Vyas
    Joseph Weinstein <[email protected]> wrote:
    JS wrote:
    It seems useful (for performance reasons) to reuse a prepared
    statement
    in
    subsequent calls to the database. In WebLogic, however, after each
    call
    we
    return the Connection object to the WebLogic connection pool. A
    prepared
    statement is created on a specific Connection object. The next timewe
    want
    to use the same query we get a Connection from the pool, which
    might
    be
    another instance of the Connection class. Therefor it seemsimpossible
    or at
    least dangerous to reuse the same prepared statement. Even in the
    case
    this
    would work we're indirectly using the other Connection, which we
    already
    returned to the pool and which could be retrieved from the pool bysomeone
    else. So, can't we reuse preparedstatements ?We already have you covered! Weblogic caches PreparedStatements along
    with the pooled connection they came from. Every time you obtain a
    pool
    connection and run a prepareStatement() or prepareCall(), we willtransparently
    give you a previously made statement, if the SQL exactly matches, andno
    other place in the current thread stack is using that statement(multiples
    can
    be cached)
    You are correct, of course, that statements you have should only
    be
    useable
    to you while you have the connection from which they came. We have
    you
    covered
    there too. If you were to try to use any prepared statement that
    you'd
    gotten
    from
    a pool connection after you'd put the connection back into the pool,those
    statements
    would throw an exception saying that they had been made inoperable atthe
    time
    you'd closed the connection.
    Joe Weinstein at B.E.A.

  • PreparedStatement and empty String instead of space

    Hi all, I would test a space value in a varchar field, i.e.:
    PreparedStatement ps=con.prepareStatement();
    String qry = "select a from table where b=? and c=?";
    ps.setString(1,"value");
    ps.setString(2," "); // space!!
    That source code doesn't work: it set "" (empty String) in the second field, not " " (space).
    Can I use PrepareStatement in any way to do this or I have to use only Statement?
    Thanks.
    Bye.

    my friend, the question was: how do you know the
    parameter is set to "" (empty string)?I don't know: I suppose!!! because it's the only reason for that it returns no record. I tested my query in this three ways:
    1) directly in sqlplus: SELECT OCCFASE As fase, OCLCVVC as convRat, SUM(QTA1) As qta1UM, SUM(QTA2) As qta2UM
    FROM DJITMPRE WHERE OCCFASE IN ('I','P') AND OCCCOSC='XXXXX' AND OCCITEM='RUG-02' AND OCCTPVR = 'RUG'
    AND OCCVAR1 = '01' AND OCCVAR2 = 'WW' AND OCCVAR3 = '12' AND OCCTPIM = '01' AND MAGAZZINO = 'MAG03'
    AND COMMESSA = ' ' AND ORIG = ' ' AND PARTITA = ' ' AND CONFIG = 0.0 AND VANO = ' '
    GROUP BY OCCFASE, OCLCVVC
    and it returns one record.
    2) using Statement:
         Statement s = conn.createStatement();
         String societa=session.getCompanyLogisticName(DSession.TABLE_LOGISTIC);
              StringBuffer qry=new StringBuffer();
              StringBuffer whereClause=new StringBuffer();
              qry.append("SELECT OCCFASE As fase, OCLCVVC as convRat, SUM(QTA1) As qta1UM, SUM(QTA2) As qta2UM ");
              qry.append("FROM DJITMPRE ");
              qry.append("WHERE OCCFASE IN ('I','P') ");
              qry.append("AND OCCCOSC='");
              qry.append(societa);
              qry.append("' ");     
              whereClause.append("AND OCCITEM='");
              whereClause.append(b.getItemCode());
              whereClause.append("' ");
              whereClause.append("AND OCCTPVR = '");
         if (b.getVariantType().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getVariantType(), 1));
         }else{
              whereClause.append(b.getVariantType());
         whereClause.append("' ");
         whereClause.append("AND OCCVAR1 = '");
         if (b.getFirstVariant().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getFirstVariant(), 1));
         }else{
              whereClause.append(b.getFirstVariant());
         whereClause.append("' ");
         whereClause.append("AND OCCVAR2 = '");
         if (b.getSecondVariant().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getSecondVariant(), 1));
         }else{
              whereClause.append(b.getSecondVariant());
         whereClause.append("' ");
         whereClause.append("AND OCCVAR3 = '");
         if (b.getThirdVariant().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getThirdVariant(), 1));
         }else{
              whereClause.append(b.getThirdVariant());
         whereClause.append("' ");
         whereClause.append("AND OCCTPIM = '");
         if (b.getPackingType().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getPackingType(), 1));
         }else{
              whereClause.append(b.getPackingType());
         whereClause.append("' ");
         whereClause.append("AND MAGAZZINO = '");
         if (b.getWarehouseCode().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getWarehouseCode(), 1));
         }else{
              whereClause.append(b.getWarehouseCode());
         whereClause.append("' ");
         whereClause.append("AND COMMESSA = '");
         if (b.getProjectItem().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getProjectItem(), 1));
         }else{
              whereClause.append(b.getProjectItem());
         whereClause.append("' ");
         whereClause.append("AND ORIG = '");
         if (b.getSourceLot().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getSourceLot(), 1));
         }else{
              whereClause.append(b.getSourceLot());
         whereClause.append("' ");
         whereClause.append("AND PARTITA = '");
         if (b.getLotNumber().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getLotNumber(), 1));
         }else{
              whereClause.append(b.getLotNumber());
         whereClause.append("' ");
         whereClause.append("AND CONFIG = ");
         whereClause.append(b.getItemConfiguration());
         whereClause.append("AND VANO = '");
         if (b.getLocation().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getLocation(), 1));
         }else{
              whereClause.append(b.getLocation());
         whereClause.append("' ");
         qry.append(whereClause.toString());
         qry.append(" GROUP BY OCCFASE, OCLCVVC");
    ResultSet rs = s.executeQuery(qry.toString());
    and it returns one record.
    3) using PreparedStatement:
    StringBuffer qry=new StringBuffer();
    qry.append("SELECT OCCFASE As fase, OCLCVVC as convRat, SUM(QTA1) As qta1UM, SUM(QTA2) As qta2UM ");
                   qry.append("FROM DJITMPRE WHERE OCCFASE IN ('I','P') ");
                   qry.append("AND OCCCOSC='").append(societa).append("' ");
                   qry.append("AND OCCITEM=? AND OCCTPVR = ? ");
              qry.append("AND OCCVAR1 = ? AND OCCVAR2 = ? AND OCCVAR3 = ? ");
              qry.append("AND OCCTPIM = ? AND MAGAZZINO = ? AND COMMESSA = ? ");
              qry.append("AND ORIG = ? AND PARTITA = ? AND CONFIG = ? ");
              qry.append("AND VANO = ? ");
              qry.append("GROUP BY OCCFASE, OCLCVVC");
    PreparedStatement bookedQtyPS = conn.prepareStatement(qry.toString());
    bookedQtyPS.setString(1,b.getItemCode());
         if (b.getVariantType().equals("")){
              bookedQtyPS.setString(2,EscapeString.getLengthString(b.getVariantType(), 1));
         }else{
              bookedQtyPS.setString(2,b.getVariantType());
         if (b.getFirstVariant().equals("")){
              bookedQtyPS.setString(3,EscapeString.getLengthString(b.getFirstVariant(), 1));
         }else{
              bookedQtyPS.setString(3,b.getFirstVariant());
         if (b.getSecondVariant().equals("")){
              bookedQtyPS.setString(4,EscapeString.getLengthString(b.getSecondVariant(), 1));
         }else{
              bookedQtyPS.setString(4,b.getSecondVariant());
         if (b.getThirdVariant().equals("")){
              bookedQtyPS.setString(5,EscapeString.getLengthString(b.getThirdVariant(), 1));
         }else{
              bookedQtyPS.setString(5,b.getThirdVariant());
         if (b.getPackingType().equals("")){
              bookedQtyPS.setString(6,EscapeString.getLengthString(b.getPackingType(), 1));
         }else{
              bookedQtyPS.setString(6,b.getPackingType());
         if (b.getWarehouseCode().equals("")){
              bookedQtyPS.setString(7,EscapeString.getLengthString(b.getWarehouseCode(), 1));
         }else{
              bookedQtyPS.setString(7,b.getWarehouseCode());
    //cat.debug("b.getProjectItem(): "+b.getProjectItem());
         if (b.getProjectItem().equals("")){
              //cat.debug("entro in 1 b.getProjectItem().length: "+b.getProjectItem().length());
              bookedQtyPS.setString(8,EscapeString.getLengthString(b.getProjectItem(), 1));
              //bookedQtyPS.setString(8," ");
         }else{
              //cat.debug("entro in 2 b.getProjectItem().length: "+b.getProjectItem().length());
              bookedQtyPS.setString(8,b.getProjectItem());
         bookedQtyPS.setString(8," ");
    //cat.debug("b.getSourceLot(): "+b.getSourceLot());     
         if (b.getSourceLot().equals("")){
              bookedQtyPS.setString(9,EscapeString.getLengthString(b.getSourceLot(), 1));
         }else{
              bookedQtyPS.setString(9,b.getSourceLot());
         bookedQtyPS.setString(9," ");
    //cat.debug("b.getLotNumber(): "+b.getLotNumber());     
         if (b.getLotNumber().equals("")){
              bookedQtyPS.setString(10,EscapeString.getLengthString(b.getLotNumber(), 1));
         }else{
              bookedQtyPS.setString(10,b.getLotNumber());
         bookedQtyPS.setString(10," ");
    //cat.debug("b.getItemConfiguration(): "+b.getItemConfiguration());
         bookedQtyPS.setString(11,""+b.getItemConfiguration());
    //cat.debug("b.getLocation(): "+b.getLocation());     
         if (b.getLocation().equals("")){
              bookedQtyPS.setString(12,EscapeString.getLengthString(b.getLocation(), 1));
         }else{
              bookedQtyPS.setString(12,b.getLocation());
         bookedQtyPS.setString(12," ");
    ResultSet rs = bookedQtyPS.executeQuery();
    and it returns 0 records.
    I hope I explained it well.

  • PreparedStatement and open cursors

    Hi,
    i write an application where it is necessary to get a lot of preparedStatements in one connection. The preparedStatements are used
    only once and they are closed after the usage. But it seems to me that this close
    has no effect. Depending on the value in open cursors the error ORA - 01000 raises and it is not possible to get another preparedStatement without closing and opening the connection. But that increases the runtime to much and the application is a performance-critical application.
    Does anyone have an idea how to solve the problem?
    Thanks

    >
    Any thoughts what could be the problem. Only time I ever got them was because the result set, statement, connection wasn't being closed or wasn't being closed in the correct order.

Maybe you are looking for

  • Augmented reality on mobile devices (android and ios)

    Him, is there already some sort of extension for AIR 3 capable of identify visual tags for augmented reality applications on android and on iOS?

  • Browse HTM files on Memory Card

    I would like to browse html files that I have saved (using a card reader) on my memory card, but keep getting a "file not found" error message. Would some kind soul please tell me what address I should enter when using "Go To Address"? I'm using a 62

  • Can I develop externally in netbeans referencing JCAPS 5.1.2 OTDs?

    I am trying to port some old eGate 4.5.3 code into Sun JCAPS 5.1.2. I have developed a user defined OTD and have been able to unmarshall data successfully inside eDesigner. The original developer had import statements that brought in the old etd defi

  • MAC software only for Leopard?! UNFAIR!

    I'm sorry, but I find it extremely unfair that the software for the MACs only works with Leopard. I just got my phone today, I was all excited to put music on it because I don't have an iPod. So I download the software and it tells me it's not compat

  • InDesign CS4 Package command not collecting all images

    OSX 10.5.6 - InDesign CS4. Packaged a magazine document which has 56 links. Destination folder only has 14 of the links. Fonts collected OK. What is going on? I redid this 3 times and it still only collects 14 of the links. Thank you.