/**
   * Returns a <code>Reader</code> object that contains a partial <code>Clob</code> value, starting
   * with the character specified by pos, which is length characters in length.
   *
   * @param pos the offset to the first character of the partial value to be retrieved. The first
   *     character in the Clob is at position 1.
   * @param length the length in characters of the partial value to be retrieved.
   * @return <code>Reader</code> through which the partial <code>Clob</code> value can be read.
   * @throws SQLException if pos is less than 1 or if pos is greater than the number of characters
   *     in the <code>Clob</code> or if pos + length is greater than the number of characters in the
   *     <code>Clob</code>
   */
  public Reader getCharacterStream(long pos, long length) throws SQLException // @sync
      {
    if (locator_ == null) // @free
    JDError.throwSQLException(this, JDError.EXC_FUNCTION_SEQUENCE); // @free

    synchronized (locator_) // @sync
    {
      if (pos < 1
          || (pos - 1 + length) > locator_.getMaxLength()
          || length < 0) // @pdc change parm check like getSubString
      {
        JDError.throwSQLException(this, JDError.EXC_ATTRIBUTE_VALUE_INVALID);
      }
      Reader r = null;

      try {
        // @xml3 if xml column, remove xml declaration via ConvTableReader
        r =
            new ConvTableReader(
                new AS400JDBCInputStream(locator_),
                converter_.getCcsid(),
                converter_.bidiStringType_,
                isXML_); // @xml3
        r.skip(pos);
        return r;
      } catch (UnsupportedEncodingException e) {
        JDError.throwSQLException(this, JDError.EXC_INTERNAL, e);
        return null;
      } catch (IOException e) {
        JDError.throwSQLException(this, JDError.EXC_INTERNAL, e);
        return null;
      }
    }
  }
 /**
  * Constructs an AS400JDBCClobLocator object. The data for the CLOB will be retrieved as
  * requested, directly from the IBM i system, using the locator handle.
  *
  * @param locator The locator.
  * @param converter The text converter.
  */
 AS400JDBCClobLocator(
     JDLobLocator locator, ConvTable converter, Object savedObject, int savedScale) {
   locator_ = locator;
   converter_ = converter;
   savedObject_ = savedObject;
   savedScale_ = savedScale;
   maxLength_ = locator_.getMaxLength();
 }
Esempio n. 3
0
  public String getString() throws SQLException {
    if (savedObject_ != null) // @loch
    { // @loch
      // get value from RS.updateX(value)
      doConversion(); // @loch
      truncated_ = 0; // @loch
      return value_; // @loch
    } // @loch

    DBLobData data = locator_.retrieveData(0, locator_.getMaxLength());
    String value =
        converter_.byteArrayToString(data.getRawBytes(), data.getOffset(), data.getLength());
    truncated_ = 0; // @pda make consistent with other SQLData Clob classes
    return value;
  }
Esempio n. 4
0
  // @pda jdbc40
  public String getNString() throws SQLException {
    truncated_ = 0;
    outOfBounds_ = false;

    if (savedObject_ != null) // @loch
    { // @loch
      // get value from RS.updateX(value)
      doConversion(); // @loch
      truncated_ = 0;
      outOfBounds_ = false; // @loch
      return value_; // @loch
    } // @loch

    DBLobData data = locator_.retrieveData(0, locator_.getMaxLength());
    String value =
        converter_.byteArrayToString(data.getRawBytes(), data.getOffset(), data.getLength());
    return value;
  }