/** For BATCHEXECDIRECT */
  public static Result newBatchedExecuteRequest() {

    Type[] types = new Type[] {Type.SQL_VARCHAR};
    Result result = newResult(ResultConstants.BATCHEXECDIRECT);

    result.metaData = ResultMetaData.newSimpleResultMetaData(types);

    return result;
  }
  /** For CALL_RESPONSE For execution of SQL callable statements. */
  public static Result newCallResponse(Type[] types, long statementId, Object[] values) {

    Result result = newResult(ResultConstants.CALL_RESPONSE);

    result.metaData = ResultMetaData.newSimpleResultMetaData(types);
    result.statementID = statementId;
    result.valueData = values;

    return result;
  }
  /**
   * For SQLEXECUTE For execution of SQL prepared statements. The parameters are set afterwards as
   * the Result is reused
   */
  public static Result newPreparedExecuteRequest(Type[] types, long statementId) {

    Result result = newResult(ResultConstants.EXECUTE);

    result.metaData = ResultMetaData.newSimpleResultMetaData(types);
    result.statementID = statementId;
    result.valueData = ValuePool.emptyObjectArray;

    return result;
  }
  /** For BATCHEXERESPONSE for a BATCHEXECUTE or BATCHEXECDIRECT */
  public static Result newBatchedExecuteResponse(
      int[] updateCounts, Result generatedResult, Result e) {

    Result result = newResult(ResultConstants.BATCHEXECRESPONSE);

    result.addChainedResult(generatedResult);
    result.addChainedResult(e);

    Type[] types = new Type[] {Type.SQL_INTEGER};

    result.metaData = ResultMetaData.newSimpleResultMetaData(types);

    Object[][] table = new Object[updateCounts.length][];

    for (int i = 0; i < updateCounts.length; i++) {
      table[i] = new Object[] {ValuePool.getInt(updateCounts[i])};
    }

    ((RowSetNavigatorClient) result.navigator).setData(table);

    return result;
  }
示例#5
0
  private Result newColumnResult(long position, int count) throws SQLException {

    int mArraySize = 0;
    String mArrayStruct = data.getTypeStructure();
    ArrayList<Integer> dimSize = getDimSize(mArrayStruct);
    ArrayList<Integer> iterIndex = new ArrayList<>(); // go through all the array values

    for (int i = 0; i < dimSize.size(); i++) {
      mArraySize += dimSize.get(i);
    }

    // tests if the required elements exist. The limits are determined
    // by computing the product of each dimension's size
    if (!JDBCClobClient.isInLimits(mArraySize, position, count)) {
      throw JDBCUtil.outOfRangeArgument();
    }

    Type[] types = new Type[2];

    types[0] = Type.SQL_VARCHAR;
    types[1] = elementType;

    ResultMetaData meta = ResultMetaData.newSimpleResultMetaData(types);

    meta.columnLabels = new String[] {"C1", "C2"};
    meta.colIndexes = new int[] {-1, -1};
    meta.columns = new ColumnBase[2];

    ColumnBase column = new ColumnBase("", "", "", "");

    column.setType(types[0]);

    meta.columns[0] = column;
    column = new ColumnBase("", "", "", "");

    column.setType(types[1]);

    meta.columns[1] = column;

    RowSetNavigatorClient navigator = new RowSetNavigatorClient();

    for (int i = (int) position; i < position + count; i++) {
      Object[] rowData = new Object[2];

      rowData[0] = Integer.valueOf(i + 1);
      try {
        rowData[1] = data.getCell(new RasPoint(1, 1));
      } catch (RasDimensionMismatchException | RasIndexOutOfBoundsException e) {
        System.err.println("Can't get the cell at point (1, 1)");
        e.printStackTrace();
      }

      navigator.add(rowData);
    }

    Result result = Result.newDataResult(meta);

    result.setNavigator(navigator);

    return result;
  }