コード例 #1
0
  /**
   * Checks if the value of the param argument is a valid parameter position.
   *
   * <p>
   *
   * @param param position to check
   * @throws SQLException if the value of the param argument is not a valid parameter position
   */
  void checkRange(int param) throws SQLException {

    if (param < 1 || param > parameterCount) {
      String msg = param + " is out of range";

      throw JDBCUtil.outOfRangeArgument(msg);
    }
  }
コード例 #2
0
ファイル: JDBCMArray.java プロジェクト: nuest/asqldb
  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;
  }