@Override public ExecuteBatchResult executeBatch(StatementHandle h, List<List<TypedValue>> parameterValueLists) throws NoSuchStatementException { final List<Long> updateCounts = new ArrayList<>(); for (List<TypedValue> parameterValueList : parameterValueLists) { ExecuteResult executeResult = execute(h, parameterValueList, -1); final long updateCount = executeResult.resultSets.size() == 1 ? executeResult.resultSets.get(0).updateCount : -1L; updateCounts.add(updateCount); } return new ExecuteBatchResult(Longs.toArray(updateCounts)); }
@Override public ExecuteBatchResult executeBatch(StatementHandle h, List<List<TypedValue>> parameterValueLists) throws NoSuchStatementException { final List<Long> updateCounts = new ArrayList<>(); for (List<TypedValue> parameterValueList : parameterValueLists) { ExecuteResult executeResult = execute(h, parameterValueList, -1); final long updateCount = executeResult.resultSets.size() == 1 ? executeResult.resultSets.get(0).updateCount : -1L; updateCounts.add(updateCount); } return new ExecuteBatchResult(Longs.toArray(updateCounts)); }
@Override public ExecuteBatchResult executeBatch(StatementHandle h, List<List<TypedValue>> parameterValueLists) throws NoSuchStatementException { final List<Long> updateCounts = new ArrayList<>(); for (List<TypedValue> parameterValueList : parameterValueLists) { ExecuteResult executeResult = execute(h, parameterValueList, -1); final long updateCount = executeResult.resultSets.size() == 1 ? executeResult.resultSets.get(0).updateCount : -1L; updateCounts.add(updateCount); } return new ExecuteBatchResult(Longs.toArray(updateCounts)); }
Util.discard(prepareAndExecute(h, sqlCommand, -1L, -1, callback)); return new ExecuteBatchResult(Longs.toArray(updateCounts));
Util.discard(prepareAndExecute(h, sqlCommand, -1L, -1, callback)); return new ExecuteBatchResult(Longs.toArray(updateCounts));
@Override public ExecuteBatchResult executeBatch(StatementHandle h, List<List<TypedValue>> updateBatches) throws NoSuchStatementException { try { final StatementInfo info = statementCache.getIfPresent(h.id); if (null == info) { throw new NoSuchStatementException(h); } final PreparedStatement preparedStmt = (PreparedStatement) info.statement; int rowUpdate = 1; for (List<TypedValue> batch : updateBatches) { int i = 1; for (TypedValue value : batch) { // Set the TypedValue in the PreparedStatement try { preparedStmt.setObject(i, value.toJdbc(calendar)); i++; } catch (SQLException e) { throw new RuntimeException("Failed to set value on row #" + rowUpdate + " and column #" + i, e); } // Track the update number for better error messages rowUpdate++; } preparedStmt.addBatch(); } return new ExecuteBatchResult(AvaticaUtils.executeLargeBatch(preparedStmt)); } catch (SQLException e) { throw propagate(e); } }
@Override public ExecuteBatchResult executeBatch(StatementHandle h, List<List<TypedValue>> updateBatches) throws NoSuchStatementException { try { final StatementInfo info = statementCache.getIfPresent(h.id); if (null == info) { throw new NoSuchStatementException(h); } final PreparedStatement preparedStmt = (PreparedStatement) info.statement; int rowUpdate = 1; for (List<TypedValue> batch : updateBatches) { int i = 1; for (TypedValue value : batch) { // Set the TypedValue in the PreparedStatement try { preparedStmt.setObject(i, value.toJdbc(calendar)); i++; } catch (SQLException e) { throw new RuntimeException("Failed to set value on row #" + rowUpdate + " and column #" + i, e); } // Track the update number for better error messages rowUpdate++; } preparedStmt.addBatch(); } return new ExecuteBatchResult(AvaticaUtils.executeLargeBatch(preparedStmt)); } catch (SQLException e) { throw propagate(e); } }
@Override public ExecuteBatchResult prepareAndExecuteBatch(final StatementHandle h, List<String> sqlCommands) throws NoSuchStatementException { final List<Long> updateCounts = new ArrayList<>(); final Meta.PrepareCallback callback = new Meta.PrepareCallback() { private final Object monitor = new Object(); long updateCount; @Override public Object getMonitor() { return monitor; } @Override public void clear() throws SQLException {} @Override public void assign(Meta.Signature signature, Meta.Frame firstFrame, long updateCount) throws SQLException { this.updateCount = updateCount; } @Override public void execute() throws SQLException { updateCounts.add(updateCount); } }; for (String sqlCommand : sqlCommands) { Util.discard(prepareAndExecute(h, sqlCommand, -1L, -1, callback)); } return new ExecuteBatchResult(Longs.toArray(updateCounts)); }
@Override public ExecuteBatchResult executeBatchProtobuf(StatementHandle h, List<Requests.UpdateBatch> updateBatches) throws NoSuchStatementException { try { final StatementInfo info = statementCache.getIfPresent(h.id); if (null == info) { throw new NoSuchStatementException(h); } final PreparedStatement preparedStmt = (PreparedStatement) info.statement; for (Requests.UpdateBatch update : updateBatches) { int i = 1; for (Common.TypedValue value : update.getParameterValuesList()) { // Use the value and then increment preparedStmt.setObject(i++, TypedValue.protoToJdbc(value, calendar)); } preparedStmt.addBatch(); } return new ExecuteBatchResult(AvaticaUtils.executeLargeBatch(preparedStmt)); } catch (SQLException e) { throw propagate(e); } }
@Override public ExecuteBatchResult executeBatchProtobuf(StatementHandle h, List<Requests.UpdateBatch> updateBatches) throws NoSuchStatementException { try { final StatementInfo info = statementCache.getIfPresent(h.id); if (null == info) { throw new NoSuchStatementException(h); } final PreparedStatement preparedStmt = (PreparedStatement) info.statement; for (Requests.UpdateBatch update : updateBatches) { int i = 1; for (Common.TypedValue value : update.getParameterValuesList()) { // Use the value and then increment preparedStmt.setObject(i++, TypedValue.protoToJdbc(value, calendar)); } preparedStmt.addBatch(); } return new ExecuteBatchResult(AvaticaUtils.executeLargeBatch(preparedStmt)); } catch (SQLException e) { throw propagate(e); } }
@Override public ExecuteBatchResult prepareAndExecuteBatch(StatementHandle h, List<String> sqlCommands) throws NoSuchStatementException { try { // Get the statement final StatementInfo info = statementCache.getIfPresent(h.id); if (info == null) { throw new NoSuchStatementException(h); } // addBatch() for each sql command final Statement stmt = info.statement; for (String sqlCommand : sqlCommands) { stmt.addBatch(sqlCommand); } // Execute the batch and return the results return new ExecuteBatchResult(AvaticaUtils.executeLargeBatch(stmt)); } catch (SQLException e) { throw propagate(e); } }
@Override public ExecuteBatchResult prepareAndExecuteBatch(StatementHandle h, List<String> sqlCommands) throws NoSuchStatementException { try { // Get the statement final StatementInfo info = statementCache.getIfPresent(h.id); if (info == null) { throw new NoSuchStatementException(h); } // addBatch() for each sql command final Statement stmt = info.statement; for (String sqlCommand : sqlCommands) { stmt.addBatch(sqlCommand); } // Execute the batch and return the results return new ExecuteBatchResult(AvaticaUtils.executeLargeBatch(stmt)); } catch (SQLException e) { throw propagate(e); } }
@Override public ExecuteBatchResult call() { Service.ExecuteBatchResponse response = service.apply(new Service.ExecuteBatchRequest(h.connectionId, h.id, parameterValues)); return new ExecuteBatchResult(response.updateCounts); } });
@Override public ExecuteBatchResult call() { Service.ExecuteBatchResponse response = service.apply( new Service.PrepareAndExecuteBatchRequest(h.connectionId, h.id, sqlCommands)); return new ExecuteBatchResult(response.updateCounts); } });
@Override public ExecuteBatchResult call() { Service.ExecuteBatchResponse response = service.apply(new Service.ExecuteBatchRequest(h.connectionId, h.id, parameterValues)); return new ExecuteBatchResult(response.updateCounts); } });
@Override public ExecuteBatchResult call() { Service.ExecuteBatchResponse response = service.apply( new Service.PrepareAndExecuteBatchRequest(h.connectionId, h.id, sqlCommands)); return new ExecuteBatchResult(response.updateCounts); } });
@Override public ExecuteBatchResult prepareAndExecuteBatch(StatementHandle sh, List<String> sqlCommands) throws NoSuchStatementException { return new ExecuteBatchResult(new long[]{}); }
@Override public ExecuteBatchResult executeBatch(StatementHandle sh, List<List<TypedValue>> parameterValues) throws NoSuchStatementException { return new ExecuteBatchResult(new long[]{}); }