JDBC Batch Updates & PreparedStatement problems (Oracle 8i)

Hi,
we're running into problems when trying to use JDBC Batch Updates with PreparedStatement in Oracle8i.
First of all, Oracle throws a SQLException if one of the statements in the batch fails (e.g. because of a unique constraint violation). As far as I understand, a BatchUpdateException should be thrown?
The next problem is much worse:
Consider this table:
SQL> desc oktest
ID NOT NULL NUMBER(10)
VALUE NOT NULL VARCHAR2(20)
primary key is ID
When inserting in through batch updates with a PreparedStatement, I can pass 'blah' as a value for ID without getting an exception (Oracle silently converts 'blah' to zero). Only when the offending statement is the last statement in the batch, Oracle throws an exception (again, SQLException instead of BatchUpdateException).
Any comments/suggestions are appreciated.
E-mail me if you want to see the code...
Thanks,
Oliver
Oracle version info:
(Enterprise Edition Release 8.1.6.0.0, JServer Release 8.1.6.0.0, Oracle JDBC driver 8.1.6.0.0 and 8.1.7.0.0 (we're using the 'thin' driver)
CLASSPATH=/opt/oracle/product/8.1.7/jdbc/lib/classes12.zip:...
null

Please refer
http://www.oracle.com/technology/products/oracle9i/daily/jun07.html

Similar Messages

  • How are JDBC batch updates implemented by Oracle?

    When you're looking to reduce commits you typically think of JDBC batch updates.
    I'm just wondering how are these implemented by Oracle and is there ever gains to be had to reducing commits in an Oracle specific way like say using VARRAYs with procedures?

    Please refer
    http://www.oracle.com/technology/products/oracle9i/daily/jun07.html

  • More log writer contention when using JDBC Batch Updates?

    So if I'm already seeing log writer contention when I'm commiting inserts one row at a time.
    Why would I see even more contention of log writer ie. commit waits in Enterprise Manager when I batch these inserts using JDBC updates.
    Today I observed significantly more commit waits when I used JDBC batching vs commit one row at a time.

    Please refer
    http://www.oracle.com/technology/products/oracle9i/daily/jun07.html

  • JDBC Batching and XMLTYPEs

    So, this question was originally asked here...
    http://stackoverflow.com/questions/4327337/does-oracles-xmltype-support-jdbc-batch-updates
    However, that was three years ago.  Does JDBC batching still not help with performance with XMLType objects as of 11.2.0.3?

    Hi William,
    Assumming that you are batching only Statements and CallableStatements.
    When a batch of say 10 statements are send and the 5th one fails, then Oracle JDBC returns an array of update counts till the
    no of successfully executed statements , in this case it will be an array containing 4 elements( since the 5th failed).
    from this we can find out which statement has failed.
    note: this feature does not work with PreparedStatement. (to my knowledge there is no way of getting it)
    Hope this helps
    Elango.

  • Oracle 10G AS, Batch Update doesn't commit.

    Hello,
    We are using Batch uptdate to commit a set of records, but to our surprise one of the batches commits in DB and the other doesnt.
    The below pseudo code explains our scenario :
    String str1="INSERT INTO TBL1 (COL1,COL2) VALUES (?,?) ";
    String str2="UPDATE TBL2 SET COL1=? WHERE COL2=?";
    PreparedStatement pstmt1=conn.prepareStatement(str1);
    PreparedStatement pstmt2=conn.prepareStatement(str2);
    for(500 recs)
    pstmt1.addbatch();
    pstmt2.addbatch();
    On 500 Recs
    //This batch updates the DB and commits too
    pstmt1.executeBatch();
    pstmt1.clearBatch();
    con.commit();
    //The Batch executes successfully, but updates are not reflected in DB,
    //which may mean that it must not be committing in DB
    pstmt2.executeBatch();
    pstmt2.clearBatch();
    con.commit();
    - In the above, pstmt1 is an INSERT and pstmt2 is an UPDATE.
    - It so happens that at the end, DB reflects Inserts done by pstmt1, but it doesnt reflect the Updates of pstmt2.
    - We have also fired a SELECT stmt immediately after pstmt2 Execute Batch, but the updated values are not reflected.
    - Also the above scenario works absolutely fine if we use a STATEMENT instead of a PREPAREDSTATEMENT for pstmt2.
    Set up Details:
    App Server :: Oracle 10G AS for Linux 2.1,
    Database Driver :: Oracle 10G Driver which is bundled with Oracle 10G AS
    Database :: Oracle 9i
    Any ideas in this regards would be highly appreciated.
    Thanks !
    - Khyati
    Message was edited by:
    user473157

    I think this is not the right forum for this question; probably a JDBC forum or one of the Oracle AS forums.
    Kuassi

  • Batch Updates Using Oracle

    Hi,
    We are currently having problems saving data using Weblogic 6.1 sp1 and Oracle
    8.1.6. we are using Weblogic JDBC Drivers for Oracle. The data we are saving is to
    the extent of 25-50,00 records. When we are trying to this we are getting transaction
    timeout errors since this saver process is taking more than 30 seconds which is out
    rimeout limit.
    Can we do this using Batch updates?? Any code snippets or pointers will be grealty
    appreciated.
    Thank YOu,
    Sanjeev

    Can you be more specific?
    - What do you want to do exactly?
    - What are your OS and Reports versions?
    At first, it sounds a bit strange to use Reports for batch updates. A pl/sql procedure may be more suitable.
    You can schedule a report in several ways, e.g. via CRON on Unix (see RWRUN command in the 9iDS Help)).
    You can do the same via the database using the SRW package (see http://download-west.oracle.com/docs/html/A92102_01/pbr_evnt.htm#1005558 )
    You can use the Reports Queue Manager.

  • Db batch update problem

    I have a real problem with doing a batch update in SOA Suite and have tried a number of different approaches but they have all failed at some point. My requirement is really quite simple.
    I have a simple table - MY_TABLE:
    Columns:
    PK_ID - primary key
    ATTR_1 - not a primary key but selection criteria for on which to update.
    ATTR_2 - value to update
    In oracle the above update statement would look something like:
    update MY_TABLE set ATTR_2=<some value> where ATTR_1=<some value>
    However I don't want to update a single row, I want to update a number of rows at the same time based on a number of different ATTR_1 values. So my approaches so far have been:
    a) use the Update functionality of the DB Adapter. The problem with this is that the DB adapater insists on updating by primary key. I do not have the primary key, I have another column for which I want to use as the criteria. So this won't work.
    b) Create a two stage process whereby I retrieve the primary keys based on ATTR_1 and feed this into approach a). Problem is that now I need to do a select based on a list of ATTR_1 values. The Select feature of the DB adapter does not allow selection based on a number of attributes, just one. i.e. the SQL that it creates for you is something like SELECT VALUES FROM TABLE WHERE CRITERIA = <some value>. What you would really need is SELECT VALUES FROM TABLE WHERE CRITERIA IN <some value>, but the Select feature won't allow this.
    c) This brings me on to the next approach. So I am going to try and use the DB adapter in Pure SQL mode. The SQL I define is something like:
    update MY_TABLE set ATTR_2=#myValue2 where ATTR_1 in #myValue1
    To get this work I have had to do some XSLT to convert my repeating element of ATTR_1 into a concatonated string e.g. ('myValue1','myValue1','myValue1'). The XSLT to do this sort of broke the XSLT GUI in SOA Suite, but it seems to work at runtime and creates the correct XML request to the DB adapter, however no rows are being updated and there is no error message either.
    This simple DB update is seemingly beyond my grasp. Can anyone help?
    Also I have no intention of looping through BPEL doing a single update at a time. The performance hit for a large number of records would be prohibitive.
    Edited by: user10103872 on 28-Nov-2010 10:42
    Edited by: user10103872 on 28-Nov-2010 10:43

    >
    I am thinking to write a procedure call to loop the sql statement "update table_A set version_no='1';"
    >
    Please don't do that. That will result in other complex issues and is not the solution to this problem.
    When you try to do any insert, update or delete, Oracle generates UNDO (which basically has all the data to revert back the changes, in case you decide to do a rollback).
    In your case, the UNDO Table space is not sized appropriately for this large update that you are trying to run. So, you need to fix that, by sizing it appropriately or by Using Auto-Extensible Table spaces.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/undo.htm#BABJCFFE

  • PreparedStatement batch updates

    I'm trying to use a batch update with a PreparedStatement, but when my code executes
    I receive an error stating The JDBC 2.0 method is not implemented, when the code
    executes addBatch(). Does JRockit have any api documentation stating what is
    and is not implemented. Any suggestions on a workaround? I'm assuming there
    is a Weblogic specific class that will accomplish this, but I would rather not
    implement such a class unless there is no other alternative.

    Hi,
    This seems to be a JDBC driver specific question (may not be related to
    JRockit). You may post this in WebLogic JDBC news groups.
    Sathish Santhanam
    Developer Relations Engineer
    BEA Support
    "frank" <[email protected]> wrote in message
    news:3f01921a$[email protected]..
    >
    I'm using JRockit 7.0 sp2rp1
    "frank" <[email protected]> wrote:
    I'm trying to use a batch update with a PreparedStatement, but when my
    code executes
    I receive an error stating The JDBC 2.0 method is not implemented, when
    the code
    executes addBatch(). Does JRockit have any api documentation stating
    what is
    and is not implemented. Any suggestions on a workaround? I'm assuming
    there
    is a Weblogic specific class that will accomplish this, but I would
    rather
    not
    implement such a class unless there is no other alternative.

  • Problem with Batch Updates

    Hi All,
    I have a requirement where in I have to use batch updates. But if there's a problem in one of the updates, I want the rest of the updates to ingore this and continue with the next statement in the batch. Is this not one of the features in BatchUpdates in JDBC2? I have been trying to accomplish this since 2 days now. Can anyone help me with this. Can anyone please help me with this?
    FYI, I have tried the following.
    I have 3 test updates in my batch.
    2 nd statement is an erraneous statement(deliberate). Other 2 statements are fine. It is appropriatley throwing 'BatchUpdateException'. when I ckeck the "arrays of ints" reurned by executeBatch() as well as BatchUpdateException.getUpdateCounts() are returning an arrays of size '0'. If remeove the erraneous statement, behaviour is as expected.
    Thanks in advance,
    Bharani

    The next paragraph of the same API doc:
    If the driver continues processing after a failure, the array returned by the method BatchUpdateException.getUpdateCounts will contain as many elements as there are commands in the batch, and at least one of the elements will be the following:
    3. A value of -3 -- indicates that the command failed to execute successfully and occurs only if a driver continues to process commands after a command fails
    A driver is not required to implement this method.

  • More than 1 preparedStatement  object using batch update

    Hey how can I execute more than 1 preparedStatement object using batch update..Pls explain with a code(java)
    Thanks

    // turn off autocommit
    con.setAutoCommit(false);
    PreparedStatement stmt = con.prepareStatement(
         "INSERT INTO employees VALUES (?, ?)");
    stmt.setInt(1, 2000);
    stmt.setString(2, "Kelly Kaufmann");
    stmt.addBatch();
    stmt.setInt(1, 3000);
    stmt.setString(2, "Bill Barnes");
    stmt.addBatch();
    // submit the batch for execution
    int[] updateCounts = stmt.executeBatch();
    search in google for more information

  • Problem installing Oracle Linux Release 5 Update 2 from Oracle e-Delivery

    Hello
    I have been trying to install Oracle Linux Release 5 Update 2 from Oracle e-Delivery so that I can install Oracle 11g express edition beta.
    Here are the steps that I took and the problem that I am having:
    1. I downloaded the file, unzipped the file twice, which gave me 3,042 files and 13 folders with the total size = 3.07 GB.
    2. I put in the DVD and restarted my PC hoping that my PC will boot from the DVD, but instead Window started.
    I reported this issue to tech support from e-Delivery, but they referred me to contact you. Please assist.
    Julia

    3,042 files and 13 folders with the total size = 3.07 GBWhich download .zip did you choose from edelivery? Under linux-x64 I peeked "Oracle Linux Release 5 Update 2 for x86_64 (64 Bit) - DVD" file V15099-01.zip downloaded, it has just the one .iso file. You'll need to burn that to DVD, but with burn s/w that handles ISO files.
    Also keep in mind you'll need 64 bit hardware (amd/intel 64? itanium? those are different), the only *nix platform I've got handy to try it out is -x86 :(                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Oracle JDBC batch size limit

    Hi,
    Does anyone know of any limitation on the size of the JDBC batch?
    We are facing a problem while storing large feeds to DB:
    - the feed file contains 77K records in it
    - the save to DB action puts all of them in one BATCH statement and tries to save
    - unfortunately in the DB only a small amount of records are saved and the JDBC driver goes silent about the rest
    - the number of records saved from the total count of 77K varies from machine to machine: on my machine the number was something like 11K, on a testing machine it was something like 9K
    - we also know that on some machines even 40K records were saved
    The code fix for this is simple: just save in batches of 1K(or whatever small amount) until all records are saved.
    But I would rather find out that there is a JVM/JDBC configuration option to increase the number of records one BATCH statement can save at a time.
    If not, why the difference between machines? Could it be the amount of RAM available for JVM on the different machines?
    So, does anyone have any idea?
    Thanks,
    Viorel

    Hello,
    This is a forum for TopLink/JPA, so you might have better luck posting your question in the JDBC forum here:
    Java Database Connectivity (JDBC)

  • Batch updates -- JDBC

    Does any body when I do a batch update, how to track if a particular insert statement has failed in that batch...
    I know that batchUpdate retruns an int[] updatecount.. but, does it tell me which row was not inserted...
    Please help

    I have problem with executeBatch() too. I tried to simulate one error out of other 99 correct data rows by inserting a string into a date field, suppose I should get updateCounts result -3, but I got SQLException and all these 100 rows were not been inserted into database.
    Any idea? Thanx.

  • Problem in JDBC receiver Updation

    Hi friends,
        I am updating the DB using the JDBC receiver adapter.
    Tell me for the following case updation can be done or not.
      key Field       Field1       Field2
          A                  X           Y
          B                  X  
          C                  X           Y
    Consider above is the datas cmng to receiver JDBC to update the database. But here the record B has the field2 as empty in this case i should not update the record b with the field2 only field1 updation should takes place. Bcoz if i update the field2 with empty value the existing value may get deleted, hence only the field1 should be updated. Please tell me how to handle this.
    Do i need to hae 2 diff update stmt for this. Revert back for any quries.
    Thanks
    Prem
    Edited by: Prem Kumar on Sep 24, 2008 4:27 PM

    Hi,
    In JDBC receiver adapter, there is a setting in Processing tab which talks abt empty string values and how it needs to be handled.
    Interpretation of Empty String values:
    There are two options keeping it as Null value and Empty string.
    One of these option will solve ur requireement.
    Am not sure which option, do check with both.
    Regards,
    Krish

  • Update/Insert Problem with Oracle Warehouse Builder

    Hello,
    i have update/insert problem with owb.
    Situation: I have a source-table called s_account and a target table called w_account_d. In the target table are already data which was filled trough the source table inserts. Now anyone make changes on data on the target table. This changes should now give further on the source table with an update operation. But exactly here is the problem i can´t map back the data to source because that will create a loop.
    My idea was to set a trigger but i can´t find this component in owb or is anywhere hidden?
    Also i have already seen properties as CDC or conditonal loading in the property inspector of the table, but i have no idea how it works.
    Give it other possibilities to modeling this case? or can anyone me explain how i can implement this eventually with CDC?
    I look forward for your replies :)

    Hi
    thanks for your answer. I follow your suggestion and have set the constraints of both tables into the database directly.Nevertheless it doesn´t work to begin. In the next step i found by right click on a table the listpoint "configure" - I goes to "unique key" --> creation method and set here follow options: Constraint State = ENABLE, Constraint Validation = Validate. That error message that appears before by the deployment disappears yet. Now i start the job to test if the insert/update process works right. Finally it seems to work - but not really.
    My Testscenario
    1. Load the data from source table about the staging area to data warehouse table: Check - it works!
    2. Change one data record in source table
    3. Load the source table with changed data record once again to staging area: Check - it works!
    4. Load new staging area table with the changed data record to data warehouse table: Check it works! BUT, BUT i can not recognize if it is insert or update operation, then under the design window by jobs execution windows is reported "rows selected 98", Rows inserted" is empty and "rows updated" is empty. So i think works not correct, then my opinion if it works correct it should show be "rows updated" 1.
    What can yet now still be wrong or forgotten? Any ideas?
    *By the way think not 98 rows there is not important if you make an update or insert which performance. It is an example table the right tables have million of records.*
    I look forward for your answers :)

Maybe you are looking for

  • Does the imac support blu ray playback

    ????

  • RMI connections performance

    I am having problems looking up a RMI object. The Weblogic console reports the following: Wed Apr 12 23:32:11 EDT 2000:<W> <ListenThread> Connection rejected: Login timed out after 5000 msec. The socket came from host=10.0.3.13,port=1140,localport=70

  • Advice on small VC set-up

    Hi,  I need advice to set-up the best but affordable VC set-up using Skype.  Requirements:  - Set-up for conference table for 6 people - Main screen on 42inch monitor on the wall - Group calls possible - Ability to do screen/application sharing durin

  • Vector graphics import, labelling dilema

    I'm using Framemaker 10, Autodesk Illustrator Publisher, Inkscape, Windows Vista. I have imported some CAD illustrations from Autodesk Illustrator into Illustrator Publisher.  There I have labelled them. I have then saved/published them as .svg files

  • Debug icon gone from Flash Builder 4 Beta 2

    Gentlepersons, In previous versions of Flex Builder (including Flash Builder Beta 1) there was a handy debugger-launcher icon in the upper-left corner of Flash Builder's main window. It looked like a green bug.  That icon is missing from Flash Builde