Package java.sql

Examples of java.sql.BatchUpdateException


        s.addBatch("create table t(x int unique not null)");
        for (int i = 0; i < 3; i++) {
            s.addBatch("insert into t values 1");
        }

        BatchUpdateException bue = null;
        try {
            s.executeBatch();
        } catch (BatchUpdateException e) {
            bue = e;
        }
        assertNotNull("Did not get duplicate key exception", bue);

        StringWriter w = new StringWriter();
        bue.printStackTrace(new PrintWriter(w, true));

        String stackTrace = w.toString();
        if (stackTrace.indexOf("duplicate key") == -1) {
            fail("Could not see 'duplicate key' in printStackTrace()", 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

        s.addBatch("create table t(x int unique not null)");
        for (int i = 0; i < 3; i++) {
            s.addBatch("insert into t values 1");
        }

        BatchUpdateException bue = null;
        try {
            s.executeBatch();
        } catch (BatchUpdateException e) {
            bue = e;
        }
        assertNotNull("Did not get duplicate key exception", bue);

        StringWriter w = new StringWriter();
        bue.printStackTrace(new PrintWriter(w, true));

        String stackTrace = w.toString();
        if (stackTrace.indexOf("duplicate key") == -1) {
            fail("Could not see 'duplicate key' in printStackTrace()", bue);
        }
View Full Code Here

        updateCounts = resultIn.getUpdateCounts();

//#ifdef JAVA2FULL
        if (updateCounts.length != batchCount) {
            throw new BatchUpdateException("failed batch", updateCounts);
        }

//#else
/*
        if (updateCounts.length != batchCount) {
View Full Code Here

                rc = step(stmt);
                if (rc != SQLITE_DONE) {
                    reset(stmt);
                    if (rc == SQLITE_ROW)
                        throw new BatchUpdateException("batch entry " + i + ": query returns results", changes);
                    throwex();
                }

                changes[i] = changes();
            }
View Full Code Here

        StringBuffer msg = new StringBuffer(eol);
        eol += "* ";

        if(ex instanceof BatchUpdateException)
        {
            BatchUpdateException tmp = (BatchUpdateException) ex;
            if(message != null)
            {
                msg.append("* ").append(message);
            }
            else
            {
                msg.append("* BatchUpdateException during execution of sql-statement:");
            }
            msg.append(eol).append("Batch update count is '").append(tmp.getUpdateCounts()).append("'");
        }
        else if(ex instanceof SQLWarning)
        {
            if(message != null)
            {
View Full Code Here

      for (int c = 0; c < resultBatches.size(); ++c) {

        QueryCommand.ResultBatch resultBatch = resultBatches.get(c);

        if (resultBatch.command.equals("SELECT")) {
          throw new BatchUpdateException(Arrays.copyOf(counts, c));
        }

        if (resultBatch.rowsAffected != null) {
          counts[c] = (int)(long)resultBatches.get(c).rowsAffected;
        }
View Full Code Here

        warningChain = chainWarnings(warningChain, warnings);

        List<QueryCommand.ResultBatch> resultBatches = command.getResultBatches();
        if (resultBatches.size() != 1) {
          throw new BatchUpdateException(counts);
        }

        QueryCommand.ResultBatch resultBatch = resultBatches.get(0);
        if (resultBatch.rowsAffected == null) {
          counts[c] = 0;
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

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.