Package java.sql

Examples of java.sql.BatchUpdateException


                        this.sql = (String) batch[i];
                        db.prepare(this);
                        changes[i] = db.executeUpdate(this, null);
                    }
                    catch (SQLException e) {
                        throw new BatchUpdateException("batch entry " + i + ": " + e.getMessage(), changes);
                    }
                    finally {
                        db.finalize(this);
                    }
                }
View Full Code Here


     * Creates a BatchUpdateException depending on the JVM level.
     */
    public  BatchUpdateException    newBatchUpdateException
        ( LogWriter logWriter, ClientMessageId msgid, Object[] args, long[] updateCounts, SqlException cause )
    {
        BatchUpdateException bue = newBatchUpdateException
            (
             msgutil_.getCompleteMessage( msgid.msgid, args),
             ExceptionUtil.getSQLStateFromIdentifier(msgid.msgid),
             ExceptionUtil.getSeverityFromIdentifier(msgid.msgid),
             updateCounts,
             cause
             );
   
        if (logWriter != null) {
            logWriter.traceDiagnosable( bue );
        }
   
        if (cause != null) {
            bue.setNextException(cause.getSQLException());
        }

        return bue;
    }
View Full Code Here

            }
        }

        // use this constructor if we're not on Java 8 or if an error occurred
        // while using the Java 8 constructor
        BatchUpdateException batch = new BatchUpdateException
            ( message, sqlState, errorCode, squashLongs( updateCounts ) );
       
        if ( cause instanceof SQLException ) { batch.setNextException( (SQLException) cause ); }
        batch.initCause( cause );

        return batch;
    }
View Full Code Here

    }
    /** This method is overridden on JVM 8 */
    protected   BatchUpdateException   newBatchUpdateException
        ( String message, String sqlState, int errorCode, long[] updateCounts, SqlException cause  )
    {
        BatchUpdateException bue = new BatchUpdateException
            ( message, sqlState, errorCode, Utils.squashLongs( updateCounts ) );

        if (cause != null) {
            bue.initCause(cause);
        }

        return bue;
    }
View Full Code Here

     * update counts.
     */
    protected   BatchUpdateException   newBatchUpdateException
        ( String message, String sqlState, int errorCode, long[] updateCounts, SqlException cause )
    {
        return new BatchUpdateException(
            message,
            sqlState,
            errorCode,
            updateCounts,
            cause);
View Full Code Here

    } else {
      int[] newUpdateCounts = new int[endOfBatchIndex];
      System.arraycopy(updateCounts, 0,
          newUpdateCounts, 0, endOfBatchIndex);

      BatchUpdateException batchException = new BatchUpdateException(ex
          .getMessage(), ex.getSQLState(), ex
          .getErrorCode(), newUpdateCounts);
      batchException.initCause(ex);
      throw batchException;
    }
   
    return sqlEx;
  }
View Full Code Here

    addBatchItems(statement, pStmt, tableName, ++c);
    addBatchItems(statement, pStmt, tableName, ++c);

    int expectedUpdateCounts = continueBatchOnError ? 6 : 3;

    BatchUpdateException e1 = null;
    BatchUpdateException e2 = null;

    int[] updateCountsPstmt = null;
    try {
      updateCountsPstmt = pStmt.executeBatch();
    } catch (BatchUpdateException e) {
View Full Code Here

            updateCounts[i] = ((Integer) data[0]).intValue();
        }

        if (updateCounts.length != batchCount) {
            if (errorResult == null) {
                throw new BatchUpdateException(updateCounts);
            } else {
                errorResult.getMainString();

                throw new BatchUpdateException(errorResult.getMainString(),
                        errorResult.getSubString(),
                        errorResult.getErrorCode(), updateCounts);
            }
        }
View Full Code Here

            updateCounts[i] = ((Integer) data[0]).intValue();
        }

        if (updateCounts.length != batchCount) {
            if (errorResult == null) {
                throw new BatchUpdateException(updateCounts);
            } else {
                errorResult.getMainString();

                throw new BatchUpdateException(errorResult.getMainString(),
                        errorResult.getSubString(),
                        errorResult.getErrorCode(), updateCounts);
            }
        }
View Full Code Here

      sqlMap.executeBatchDetailed();
      fail("This statement should not get executed - we expect an SQLException");
    } catch (BatchException e) {
      // the first statement of the failing batch should have executed OK
      BatchUpdateException bue = e.getBatchUpdateException();
      assertEquals(1, bue.getUpdateCounts().length);

      List results = e.getSuccessfulBatchResults();
      assertEquals(2, results.size());
      BatchResult br = (BatchResult) results.get(0);
      assertEquals(5, br.getUpdateCounts().length);
View Full Code Here

TOP

Related Classes of java.sql.BatchUpdateException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.