@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 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 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); } }