/** * Converts an array of {@code long} values to an array of {@code int} * values, truncating values outside the legal range for an {@code int} * to {@link Integer#MIN_VALUE} or {@link Integer#MAX_VALUE}. * * @param longs An array of {@code long}s * @return An array of {@code int}s */ public static int[] toSaturatedInts(long[] longs) { final int[] ints = new int[longs.length]; for (int i = 0; i < longs.length; i++) { ints[i] = toSaturatedInt(longs[i]); } return ints; }
@JsonCreator public PrepareAndExecuteRequest( @JsonProperty("connectionId") String connectionId, @JsonProperty("statementId") int statementId, @JsonProperty("sql") String sql, @JsonProperty("maxRowsTotal") long maxRowCount, @JsonProperty("maxRowsInFirstFrame") int maxRowsInFirstFrame) { this.connectionId = connectionId; this.statementId = statementId; this.sql = sql; this.maxRowCount = maxRowCount; this.maxRowsInFirstFrame = maxRowsInFirstFrame; }
@JsonCreator public PrepareAndExecuteRequest( @JsonProperty("connectionId") String connectionId, @JsonProperty("statementId") int statementId, @JsonProperty("sql") String sql, @JsonProperty("maxRowsTotal") long maxRowCount, @JsonProperty("maxRowsInFirstFrame") int maxRowsInFirstFrame) { this.connectionId = connectionId; this.statementId = statementId; this.sql = sql; this.maxRowCount = maxRowCount; this.maxRowsInFirstFrame = maxRowsInFirstFrame; }
@SuppressWarnings("deprecation") public ExecuteResult prepareAndExecute(StatementHandle h, String sql, long maxRowCount, PrepareCallback callback) throws NoSuchStatementException { return prepareAndExecute(h, sql, maxRowCount, AvaticaUtils.toSaturatedInt(maxRowCount), callback); }
public int getUpdateCount() throws SQLException { checkOpen(); return AvaticaUtils.toSaturatedInt(updateCount); }
@SuppressWarnings("deprecation") @Override public ExecuteResult execute(StatementHandle h, List<TypedValue> parameterValues, long maxRowCount) throws NoSuchStatementException { return execute(h, parameterValues, AvaticaUtils.toSaturatedInt(maxRowCount)); }
@Override public ExecuteResult execute(StatementHandle h, List<TypedValue> parameterValues, long maxRowCount) throws NoSuchStatementException { return execute(h, parameterValues, AvaticaUtils.toSaturatedInt(maxRowCount)); }
@SuppressWarnings("deprecation") @Override public ExecuteResult prepareAndExecute(StatementHandle h, String sql, long maxRowCount, PrepareCallback callback) throws NoSuchStatementException { // The old semantics were that maxRowCount was also treated as the maximum number of // elements in the first Frame of results. A value of -1 would also preserve this, but an // explicit (positive) number is easier to follow, IMO. return prepareAndExecute(h, sql, maxRowCount, AvaticaUtils.toSaturatedInt(maxRowCount), callback); }
@SuppressWarnings("deprecation") public ExecuteResult prepareAndExecute(StatementHandle h, String sql, long maxRowCount, PrepareCallback callback) throws NoSuchStatementException { return prepareAndExecute(h, sql, maxRowCount, AvaticaUtils.toSaturatedInt(maxRowCount), callback); }
@SuppressWarnings("deprecation") @Override public ExecuteResult prepareAndExecute(StatementHandle h, String sql, long maxRowCount, PrepareCallback callback) throws NoSuchStatementException { // The old semantics were that maxRowCount was also treated as the maximum number of // elements in the first Frame of results. A value of -1 would also preserve this, but an // explicit (positive) number is easier to follow, IMO. return prepareAndExecute(h, sql, maxRowCount, AvaticaUtils.toSaturatedInt(maxRowCount), callback); }
public int getUpdateCount() throws SQLException { checkOpen(); return AvaticaUtils.toSaturatedInt(updateCount); }
@SuppressWarnings("deprecation") @Override public ExecuteResult execute(StatementHandle h, List<TypedValue> parameterValues, long maxRowCount) throws NoSuchStatementException { return execute(h, parameterValues, AvaticaUtils.toSaturatedInt(maxRowCount)); }
public final int getMaxRows() throws SQLException { return AvaticaUtils.toSaturatedInt(getLargeMaxRows()); }
public final int getMaxRows() throws SQLException { return AvaticaUtils.toSaturatedInt(getLargeMaxRows()); }
public final int executeUpdate(String sql) throws SQLException { return AvaticaUtils.toSaturatedInt(executeLargeUpdate(sql)); }
public final int executeUpdate() throws SQLException { return AvaticaUtils.toSaturatedInt(executeLargeUpdate()); }
public final int executeUpdate() throws SQLException { return AvaticaUtils.toSaturatedInt(executeLargeUpdate()); }
public final int executeUpdate(String sql) throws SQLException { return AvaticaUtils.toSaturatedInt(executeLargeUpdate(sql)); }
public ExecuteResponse apply(ExecuteRequest request) { try (final Context ignore = executeTimer.start()) { try { final Meta.ExecuteResult executeResult = meta.execute(request.statementHandle, request.parameterValues, AvaticaUtils.toSaturatedInt(request.maxRowCount)); final List<ResultSetResponse> results = new ArrayList<>(executeResult.resultSets.size()); for (Meta.MetaResultSet metaResultSet : executeResult.resultSets) { results.add(toResponse(metaResultSet)); } return new ExecuteResponse(results, false, serverLevelRpcMetadata); } catch (NoSuchStatementException e) { return new ExecuteResponse(null, true, serverLevelRpcMetadata); } } }
public ExecuteResponse apply(ExecuteRequest request) { try (final Context ignore = executeTimer.start()) { try { final Meta.ExecuteResult executeResult = meta.execute(request.statementHandle, request.parameterValues, AvaticaUtils.toSaturatedInt(request.maxRowCount)); final List<ResultSetResponse> results = new ArrayList<>(executeResult.resultSets.size()); for (Meta.MetaResultSet metaResultSet : executeResult.resultSets) { results.add(toResponse(metaResultSet)); } return new ExecuteResponse(results, false, serverLevelRpcMetadata); } catch (NoSuchStatementException e) { return new ExecuteResponse(null, true, serverLevelRpcMetadata); } } }