/** * Execute the current batch of statements. If any exception occurs * during execution, a {@link org.apache.phoenix.exception.BatchUpdateException} * is thrown which includes the index of the statement within the * batch when the exception occurred. */ @Override public int[] executeBatch() throws SQLException { int i = 0; try { int[] returnCodes = new int [batch.size()]; for (i = 0; i < returnCodes.length; i++) { PhoenixPreparedStatement statement = batch.get(i); returnCodes[i] = statement.execute(true) ? Statement.SUCCESS_NO_INFO : statement.getUpdateCount(); } // Flush all changes in batch if auto flush is true flushIfNecessary(); // If we make it all the way through, clear the batch clearBatch(); return returnCodes; } catch (Throwable t) { throw new BatchUpdateExecution(t,i); } }
@Override public int executeUpdate(String sql) throws SQLException { CompilableStatement stmt = parseStatement(sql); if (!stmt.getOperation().isMutation) { throw new ExecuteUpdateNotApplicableException(sql); } if (!batch.isEmpty()) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH) .build().buildException(); } int updateCount = executeMutation(stmt); flushIfNecessary(); return updateCount; }
@Override public boolean execute(String sql) throws SQLException { CompilableStatement stmt = parseStatement(sql); if (stmt.getOperation().isMutation()) { if (!batch.isEmpty()) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH) .build().buildException(); } executeMutation(stmt); flushIfNecessary(); return false; } executeQuery(stmt,createQueryLogger(stmt,sql)); return true; }
/** * Execute the current batch of statements. If any exception occurs * during execution, a {@link org.apache.phoenix.exception.BatchUpdateException} * is thrown which includes the index of the statement within the * batch when the exception occurred. */ @Override public int[] executeBatch() throws SQLException { int i = 0; try { int[] returnCodes = new int [batch.size()]; for (i = 0; i < returnCodes.length; i++) { PhoenixPreparedStatement statement = batch.get(i); returnCodes[i] = statement.execute(true) ? Statement.SUCCESS_NO_INFO : statement.getUpdateCount(); } // Flush all changes in batch if auto flush is true flushIfNecessary(); // If we make it all the way through, clear the batch clearBatch(); return returnCodes; } catch (Throwable t) { throw new BatchUpdateExecution(t,i); } }
/** * Execute the current batch of statements. If any exception occurs * during execution, a {@link org.apache.phoenix.exception.BatchUpdateException} * is thrown which includes the index of the statement within the * batch when the exception occurred. */ @Override public int[] executeBatch() throws SQLException { int i = 0; try { int[] returnCodes = new int [batch.size()]; for (i = 0; i < returnCodes.length; i++) { PhoenixPreparedStatement statement = batch.get(i); returnCodes[i] = statement.execute(true) ? Statement.SUCCESS_NO_INFO : statement.getUpdateCount(); } // Flush all changes in batch if auto flush is true flushIfNecessary(); // If we make it all the way through, clear the batch clearBatch(); return returnCodes; } catch (Throwable t) { throw new BatchUpdateExecution(t,i); } }
@Override public int executeUpdate(String sql) throws SQLException { CompilableStatement stmt = parseStatement(sql); if (!stmt.getOperation().isMutation) { throw new ExecuteUpdateNotApplicableException(sql); } if (!batch.isEmpty()) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH) .build().buildException(); } int updateCount = executeMutation(stmt); flushIfNecessary(); return updateCount; }
@Override public int executeUpdate(String sql) throws SQLException { CompilableStatement stmt = parseStatement(sql); if (!stmt.getOperation().isMutation) { throw new ExecuteUpdateNotApplicableException(sql); } if (!batch.isEmpty()) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH) .build().buildException(); } int updateCount = executeMutation(stmt); flushIfNecessary(); return updateCount; }
@Override public boolean execute(String sql) throws SQLException { CompilableStatement stmt = parseStatement(sql); if (stmt.getOperation().isMutation()) { if (!batch.isEmpty()) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH) .build().buildException(); } executeMutation(stmt); flushIfNecessary(); return false; } executeQuery(stmt,createQueryLogger(stmt,sql)); return true; }
@Override public boolean execute(String sql) throws SQLException { CompilableStatement stmt = parseStatement(sql); if (stmt.getOperation().isMutation()) { if (!batch.isEmpty()) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH) .build().buildException(); } executeMutation(stmt); flushIfNecessary(); return false; } executeQuery(stmt,createQueryLogger(stmt,sql)); return true; }