BatchUpdateException.getUpdateCounts() problem

When error ouccurs using statement.addbatch() and statement.executeBatch() in JDBC 2.0, I want to see how many statements are sucessfully excuted and at what point the error ouccured. So I used BatchUpdateException.getUpdateCount(). however, in the int[] returned, all elements contain -3, which is flag for EXECUTION_FAILED. this int[] supposed to have either the affected line number for each statements, or a -2, the SUCESS_NO_INFO for the all suceesed statements, and have -3 for all failed ones.
please help

I agree. I am in the same dilemma. I really need to know which one failed in the batch. I think oracle is not in compliance with the JDBC specs.

Similar Messages

  • 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.

  • BatchUpdateException :Results returned for UPDATE ONLY.

    I got an error message at the statement stmt.executeBatch();
    java.sql.BatchUpdateException: Results returned for UPDATE ONLY.
    There are 3 SQL commands in the batch and it throws the above exception while executing the first command.
    (The first command is a SELECT command with COUNT returned to a variable
    eg. SELECT @ABC := COUNT(*) ....
    The second and the third commands use the returned variable to make updates)
    I printed out the updated information using BatchUpdateException.getUpdateCounts and I got
    -3 1 1 (-3 means Statement.EXECUTE_FAILED)
    However, I checked the database (mysql) and I discovered those two update commands were executed correctly ???!!!
    An interesting thing is: if I use stmt.execute or stmt.executeQuery instead of executeBatch, it works fine and doesn't throw any exception.
    I wonder if anybody experience similar situation before or have idea on this problem. Thanx :)

    Can somebody help me, please?

  • Batch Updates in JDBC2

    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

    Cross posted...
    http://forum.java.sun.com/thread.jsp?thread=392858&foru
    =31&message=1701232there's no post
    like a cross-post
    it's the most annoying thing around
    so if you want
    to get some help
    don't cross-post yourself into the ground

  • ExecuteBatch(): number of successfully updated rows

    Hello everybody:
    Here is a simple but often a repeated question in java forums:
    Requirement:
    1.To read a flat file that has many rows of data.
    2.Parse the data and update the database accordingly.
    3.Find the number of successfully updated rows.
    Approach:
    After reading the file and parsing its data,
    - use PreparedStatement
    - use executeBatch()
    I found this as unadvisable to use executeBatch() as its implementation is
    inherently driver specific. The executeBatch() returns an array of update counts.
    Now,can any one tell me, what is the best way to trace the number of successfully
    (and unsuccessfully) updated rows by using this count?
    Is there any other way to achieve the same by not using executeBatch()?
    Can any one share a snippet of code to achieve this specific functionality?
    [Need is to log the number of unsuccessful attempts along with their
    corresponding rows of data].
    Thanks & regards,
    Venkat Kosigi

    executeBatch submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts. The int elements of the array that is returned are ordered to correspond to the commands in the batch, which are ordered according to the order in which they were added to the batch. The elements in the array returned by the method executeBatch may be one of the following:
    -- A number greater than or equal to zero indicates that the command was processed successfully and is an update count giving the number of rows in the database that were affected by the command's execution
    -- A value of -2 indicates that the command was processed successfully but that the number of rows affected is unknown
    If one of the commands in a batch update fails to execute properly, this method throws a BatchUpdateException, and a JDBC driver may or may not continue to process the remaining commands in the batch. However, the driver's behavior must be consistent with a particular DBMS, either always continuing to process commands or never continuing to process commands.
    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:
    -- 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.
    return values have been modified in the Java 2 SDK, Standard Edition, version 1.3 to accommodate the option of continuing to proccess commands in a batch update after a BatchUpdateException obejct has been thrown.
    Throws BatchUpdateException (a subclass of SQLException) if one of the commands sent to the database fails to execute properly or attempts to return a result set. The BatchUpdateException getUpdateCounts() method allows you to known the element who caused the fail identified by a -3 value.
    -- So, if you have a succesfully result, look for at the executeBatch returned array ( #values >= 0 ) + ( #values == -2 ) = successes
    and if you have not a succesfully result, catching the BatchUpdateException take the array returned by the getUpdateCounts() method, and look for the position in which array values are -3. You could take the data at this position on batch and log it.
    -- Other way to insert a bulk copy on database is to use a bcp command ( it�s not java, bcp is an independent command ) that allows you to do bulk inserts from file, indicate an error file, bcp will give to you as result a file with those lines not where inserted.
    I hope have help you.;)

  • Oracle setExecuteBatch() func

    So within my code I have setup an execute batch to be run every 5000 queries. Using the setExecuteBatch() method specific to the oracle api, like so:
    ((OraclePreparedStatement)broker.pstmt).setExecuteBatch(5000);
    broker.pstmt.executeUpdate();
    So when I call executeUpdate() on a preparedstatement execution will only occur when the batch has 5000 records in it.
    However, if let's say the query 1000 within the 5000 query batch is incorrect and Oracle is executing the batch a SQLException will be triggered.
    Is there a way to know exactly where within the batch this error has occured ? I.e which of those 5000 queries is erroneous.

    From the JDBC 3.0 Specification - Final Release
    (jdbc-3_0-fr-spec.pdf) available for downloading from the Sun site:
    15.1.3 Handling Failures during Execution
    A JDBC driver may or may not continue processing the
    remaining commands in a batch once execution of a command fails.
    However, a JDBC driver must always provide the same behaviour with a
    particular data source. For example, a driver
    cannot continue processing after a failure for one batch and not
    continue processing for another batch.
    If a driver stops processing after the first failure, the array
    returned by the method BatchUpdateException.getUpdateCounts will always
    contain fewer entries than there were statements in the batch. Since
    statements are executed in the order that they are added to the batch,
    if the array contains N elements, this means that the first N elements
    in the batch were processed successfully when executeBatch was called.
    When a driver continues processing in the presence of failures, the
    number of elements in the array returned by the method
    BatchUpdateException.getUpdateCounts always equals the number of
    commands in the batch. When a BatchUpdateException object is thrown and
    the driver continues processing after a failure, the array of update
    counts will contain the following BatchUpdateException constant:
    * Statement.EXECUTE_FAILED � the command failed to execute successfully.
    This value is also returned for commands that could not be processed
    for some reason�such commands fail implicitly.

  • Problem in getting correct update records count while getUpdateCount()

    hi,
    I have used "Select in Insert" queries for migrating data from one table to another.
    like
    INSERT INTO TABLE1 (COL1, COL2)
    SELECT COL1,COL2,... FROM TABLE2
    WHERE COL1 = ... AND COL2 = ...;
    Case 1:
    I added these statements as addBatch() & at the end i execute method " executeBatch()".
    Then i execute
    getUpdateCount() method
    on that prepareStatement ,but that count was not correct all the time.
    Case 2:
    If i run the same code with executeUpdate() method , it returned me the correct number of records counts that are inserted into the table.
    I cudn't able to understand that it is failing for case1.
    Can anybody tell the reason for this behaviour .......................
    Edited by: user11187328 on Mar 18, 2010 4:52 AM

    hi,
    Thanks again for a correct reply but can u also tell me tht which jar i needs to included.
    There are so many jar files & should i remove old jar files or jvm auto picks the updated jar file.
    Following jar files are shown on the link:::
    ojdbc5.jar (1,996,228 bytes) - Classes for use with JDK 1.5. It contains the JDBC driver classes, except classes for NLS support in Oracle Object and Collection types.
    ojdbc5_g.jar (3,081,328 bytes) - Same as ojdbc5.jar, except that classes were compiled with "javac -g" and contain tracing code.
    ojdbc6.jar (2,111,220 bytes) - Classes for use with JDK 1.6. It contains the JDBC driver classes except classes for NLS support in Oracle Object and Collection types.
    ojdbc6_g.jar (3,401,519 bytes) - Same as ojdbc6.jar except compiled with "javac -g" and contains tracing code.
    ojdbc5dms.jar (2,429,777 bytes) - Same as ojdbc5.jar, except that it contains instrumentation to support DMS and limited java.util.logging calls.
    ojdbc5dms_g.jar (3,101,875 bytes) - Same as ojdbc5_g.jar, except that it contains instrumentation to support DMS.
    ojdbc6dms.jar (2,655,741 bytes) - Same as ojdbc6.jar, except that it contains instrumentation to support DMS and limited java.util.logging calls.
    ojdbc6dms_g.jar (3,423,263 bytes) - Same as ojdbc6_g.jar except that it contains instrumentation to support DMS.
    orai18n.jar (1,656,280 bytes) - NLS classes for use with JDK 1.5, and 1.6. It contains classes for NLS support in Oracle Object and Collection types. This jar file replaces the old nls_charset jar/zip files.
    demo.zip (603,363 bytes) - contains sample JDBC programs.

  • BatchUpdateException Problems

    I am trying to play around the batch update method provided in JAVA API 1.3. It works but not without errors. I keep on insert 5 records into my DB2 table by using back the same records. The result is, sometime my code works properly, but sometime it will give me a BatchUpdateException. And I don't know why this could be happened. Attached are the code snippet and also the error log.
    Thanks for any advise and reply.
    // Code Snippet
    if (connection == null) connection = connectDB(); //open connection
    if (stmt != null) stmt = null;
    sqlQuery = "INSERT INTO FAVOURITE (STAFFID, NAME, ACCTNO) VALUES(?,?,?);
    connection.setAutoCommit(false);
    stmt = connection.prepareStatement(sqlQuery);
    for (int j = 0; j < 5; j++) {
       stmt.setString(1, staffID[j]);
       stmt.setString(2, staffName[j]);
       stmt.setString(3, staffAcct[j]);
       stmt.addBatch();
    int [] numUpdates = stmt.executeBatch();
    connection.commit();
    stmt.clearBatch();
    // end code snippet
    // Start error log
    [11/1/04 22:18:41:086 MYT] 21ab3697 LocalTransact E WLTC0033E: Resource jdbc/dev rolled back in cleanup of unresolved LocalTransactionContainment.
    [11/1/04 22:18:41:089 MYT] 21ab3697 LocalTransact E WLTC0032E: One or more resou
    rces rolled back. An unresolved LocalTransactionContainment had an unresolved ac
    tion of rollback.
    [11/1/04 22:18:41:091 MYT] 21ab3697 WebAppTransac E SRVE0183E: LocalTransaction
    rolled-back due to setRollbackOnly
    [11/1/04 22:18:41:095 MYT] 21ab3697 WebGroup      E SRVE0026E: [Servlet Error]-[
    LocalTransaction rolled-back due to setRollbackOnly]: com.ibm.ws.LocalTransactio
    n.RolledbackException
            at com.ibm.ws.LocalTransaction.LocalTranCoordImpl.cleanup(LocalTranCoord
    Impl.java(Compiled Code))
            at com.ibm.ws.webcontainer.webapp.WebAppTransactionCollaborator.postInvo
    ke(WebAppTransactionCollaborator.java(Compiled Code))
            at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAp
    pRequestDispatcher.java(Compiled Code))
            at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebApp
    RequestDispatcher.java(Compiled Code))
            at com.ibm.ws.webcontainer.servlet.InvokerServlet.service(InvokerServlet
    .java:255)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code
            at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(Stric
    tServletInstance.java(Compiled Code))
            at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(Stric
    tLifecycleServlet.java(Compiled Code))
            at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecy
    cleServlet.java(Compiled Code))
            at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(Strict
    LifecycleServlet.java(Inlined Compiled Code))
            at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstan
    ce.java(Compiled Code))
            at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(V
    alidServletReferenceState.java(Compiled Code))
            at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(Ser
    vletInstanceReference.java(Inlined Compiled Code))
            at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDi
    spatch(WebAppRequestDispatcher.java(Compiled Code))
            at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAp
    pRequestDispatcher.java(Compiled Code))
            at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebApp
    RequestDispatcher.java(Compiled Code))
            at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.jav
    a(Compiled Code))
            at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebApp
    Invoker.java(Compiled Code))
            at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvoc
    ation(CachedInvocation.java(Compiled Code))
            at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(Ser
    vletRequestProcessor.java(Compiled Code))
            at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSE
    Listener.java(Compiled Code))
            at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnect
    ion.java(Compiled Code))
            at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.ja
    va(Compiled Code))
            at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:449)
            at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
    //end error log

    I would suggest that you google using the following string....
    "An unresolved LocalTransactionContainment"

  • JDBC BatchUpdateException

    I have the following problem:
    If I try to insert values to a database table with a batch update and somehing goes wrong during statement.executeBatch() (e.g a unique
    constraint is violated), the Oracle driver throws a SQLException instead of an BatchUpdateException and I have no chance to get the updatecount with BatchUpdateException buex.getUpdateCounts().
    Am I wrong or is the driver buggy?
    Any ideas how I can remove the faulty batch element and commit the correct elements?
    Thanks,
    Immo
    I'm using the Oracle8i 8.1.6.0.1 JDBC 2.0 compliant driver for use with JDK 1.2.x
    This is the Exception: java.sql.SQLException: ORA-00001: unique constraint (BERND.SYS_C00946) violated

    Hi,
    I've logged a bug on this.
    It seems likely that the problem has arisen because one of your tables has a non-integer value for one of its volumetric properties (Minimum, Expected or Maximum volume).
    (If this is the case, then the problem will probably still occur with the DM 4.1 EA1 version.)
    David

  • GetUpdateCount()

    I have got one problem with Oracle Driver. As per the documents if I am executing getUpdateCount() two times & I know I execute method will return only one time updateCount then if I am calling getUpdateCount() second time it returns me the same value as during the first time execution.
    I studied various material for ex.
    5.1.3 Using the Method Execute
    The execute method should be used only when it is possible that a statement may return more than one ResultSet object, more than one update count, or a combination of ResultSet objects and update counts. These multiple possibilities for results, though rare, are possible when one is executing certain stored procedures or dynamically executing an unknown SQL string (that is, unknown to the application programmer at compile time). For example, a user might execute a stored procedure (using a CallableStatement object-see Section 8, "CallableStatement," of this JDBC Guide), and that stored procedure could perform an update, then a select, then an update, then a select, and so on. Typically someone using a stored procedure will know what it returns.
    Because the method execute handles the cases that are out of the ordinary, it is no surprise that retrieving its results requires some special handling. For instance, suppose it is known that a procedure returns two result sets. After using the method execute to execute the procedure, one must call the method getResultSet to get the first result set and then the appropriate getXXX methods to retrieve values from it. To get the second result set, one needs to call getMoreResults and then getResultSet a second time. If it is known that a procedure returns an update count, the method getUpdateCount is called.
    Those cases where one does not know what will be returned are more complicated. The method execute returns true if the result is a ResultSet object and false if it is a Java int. If it returns an int, that means that the result is either an update count or that the statement executed was a DDL command. The first thing to do after calling the method execute, is to call either getResultSet or getUpdateCount. The method getResultSet is called to get what might be the first of two or more ResultSet objects; the method getUpdateCount is called to get what might be the first of two or more update counts.
    When the result of an SQL statement is not a result set, the method getResultSet will return null. This can mean that the result is an update count or that there are no more results. The only way to find out what the null really means in this case is to call the method getUpdateCount, which will return an integer. This integer will be the number of rows affected by the calling statement or -1 to indicate either that the result is a result set or that there are no results. If the method getResultSet has already returned null, which means that the result is not a ResultSet object, then a return value of -1 has to mean that there are no more results. In other words, there are no results (or no more results) when the following is true:
    ((stmt.getResultSet() == null) && (stmt.getUpdateCount() == -1))
    If one has called the method getResultSet and processed the ResultSet object it returned, it is necessary to call the method getMoreResults to see if there is another result set or update count. If getMoreResults returns true, then one needs to again call getResultSet to actually retrieve the next result set. As already stated above, if getResultSet returns null, one has to call getUpdateCount to find out whether null means that the result is an update count or that there are no more results.
    Here as per this I should get -1 during the second time execution but with Oracle it is not. why? Is there any fix for this?

    Becuase you are calling getUpdateCount() twice, while condition and trace.

  • Statement.getUpdateCount() is not working

    Hi
    I'm using the Thin driver, and getUpdateCount() is never returning -1, no matter how many times I do a getMoreResults()
    Thus I can't be sure if all results have been read.
    HELP!!
    null

    I'm having the same problem with both the Thin and OCI JDBC drivers in Oracle 8i 8.1.6. Any help on this would be greatly appreciated.
    I have a while loop that generically checks for update counts and result sets after calling the execute function of a Statement object. As the person stated below, getUpdateCount never returns a -1 and I get into an infinite loop. I am using the getUpdateCount, getResultSet and getMoreResults methods in conjunction with the execute method.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Marcos Scriven ([email protected]):
    Hi
    I'm using the Thin driver, and getUpdateCount() is never returning -1, no matter how many times I do a getMoreResults()
    Thus I can't be sure if all results have been read.
    HELP!!<HR></BLOCKQUOTE>
    null

  • Oracle Batch update problem

    Hi,
    I have a queer problem with batch inserts in oracle, loaded on a sun solaris m/c.
    I'm trying to do a batch insert using the executeBatch() api of java.
    I am able to do batch insertions from my workstation i.e win2k properly . But i'm unable to do so when i run the program on the sun solaris m/c.(The data base is the same)
    Since the JVMs are different i have a feeling it could be the oracle JVM that is giving the problem.
    Please advice me as to how i can overcome this.

    I am having the same problem with a 9i installation on Win2k. My code works fine when run in the Sun JVM on a client. When I try to executeBatch in the Oracle JVM, I get "java.sql.BatchUpdateException: Internal Error: oracle.jdbc.kprb.KprbDBStatement".
    I am using what I thought was the standard preparedStatement.addBatch() and preparedStatement.executeBatch() APIs.
    I see in the SetExecuteBatch.java example the use of connection.setDefaultExecuteBatch(int) and preparedStatement.executeUpdate(). Is this usage required when running in the Oracle JVM? What if I set my batch size to 10000 but I only have 9000 rows in the last set -- how do I force the batch to execute on the smaller set?

  • I am stcuk in error exception  java.sql.BatchUpdateException

    Dear,
    I have write a program which reads data from a file and write in a database Postrgresql.But when i run my program it shows the error after some time running.It shows the exception which is
    "java.sql.BatchUpdateException: Batch entry 122,098 INSERT INTO GEONAME VALUES (3294551)"
    "at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2516)"
    These are the exceptions can anyone please help me to remove this.
    Thanks

    That might be telling you about a specific error in the sequence of batch commands that you are processing.
    Try retrieving the getUpdateCounts() from that exception and print the results.

  • 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

  • PreparedStatement.executeBatch() and BatchUpdateException

    Hi,
    I am using PreparedStatement's executeBatch() method to make batch operations,
    for such a scenario is there a way to continue the operation 3 and 4 when the operation 2 fails?
    operation 1 (will succeed alone)
    operation 2 (will fail alone)
    operation 3 (will succeed alone)
    operation 4 (will succeed alone)

    Hi, I've already looked the link you've sent.
    Let me give more detail about the result of my scenario.
    The first two successfull insert operations really updates the database which is Oracle.
    But it seems the failed 3rd operation prevents the operation 4 to update database.
    My code is something like that:
    int[] updateCounts = null;
    try {
    PreparedStatement stmtInsert = conn.prepareStatement("insert sql");
    for (int i=0; i <SOMEVALUE; i++)
         stmtInsert.setString(1, SOMEVALUE);
         stmtInsert.setString(2, SOMEVALUE);
         stmtInsert.addBatch();
    int[] counts = stmtInsert.executeBatch();
    } catch (BatchUpdateException e)
    updateCounts = e.getUpdateCounts();
    checkUpdateCounts(updateCounts);
    finally {
    conn.close();
    public static void checkUpdateCounts(int[] updateCounts) {
    for (int i = 0; i < updateCounts.length; i++) {
    if (updateCounts[i] == Statement.SUCCESS_NO_INFO) {
    // Successfully executed; number of affected rows not available
    System.out.println("Statement.SUCCESS_NO_INFO");
    } else if (updateCounts[i] == Statement.EXECUTE_FAILED) {
    System.out.println("Statement.EXECUTE_FAILED");
    The results are pretty confusing, as I said first two operations updates the db, but fourth is did not.
    But system out says:
    Statement.EXECUTE_FAILED
    Statement.EXECUTE_FAILED
    Statement.EXECUTE_FAILED
    Statement.EXECUTE_FAILED
    I would expect something like that:
    Statement.SUCCESS_NO_INFO");
    Statement.SUCCESS_NO_INFO");
    Statement.EXECUTE_FAILED
    Statement.EXECUTE_FAILED
    or even better (assuming operation 4 updated the db)
    Statement.SUCCESS_NO_INFO");
    Statement.SUCCESS_NO_INFO");
    Statement.EXECUTE_FAILED
    Statement.SUCCESS_NO_INFO");
    Since the size of the int array that the e.getUpdateCounts() is 4 which is also equal of the batch operations' size, I assume that the driver continues to process the commands in the batch after a BatchUpdateException is thrown.
    I am totally confused, can anybody comment these results? Is there a way to succeed the fourth operation?

Maybe you are looking for