當前位置: 首頁>>代碼示例>>Java>>正文


Java Clob.getSubString方法代碼示例

本文整理匯總了Java中java.sql.Clob.getSubString方法的典型用法代碼示例。如果您正苦於以下問題:Java Clob.getSubString方法的具體用法?Java Clob.getSubString怎麽用?Java Clob.getSubString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.sql.Clob的用法示例。


在下文中一共展示了Clob.getSubString方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: clobToString

import java.sql.Clob; //導入方法依賴的package包/類
public static String clobToString(Clob clobValue) {
    StringBuilder contentPart = new StringBuilder();
    try {
        long size = clobValue.length();
        long retrievalCount = Math.min(size, 255);
        String sampleContent = clobValue.getSubString(1, (int) retrievalCount);
        contentPart.append(sampleContent.replaceAll("[\n\r]+", " "));//NOI18N
        if (size > 255) {
            contentPart.append(" [...]");                           //NOI18N
        }
        return contentPart.toString();
    } catch (SQLException ex) {
        LOG.log(Level.INFO,
                "Failed to retrieve CLOB content", //NOI18N
                ex);
        return clobToDescription(clobValue);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:LobHelper.java

示例2: getClobAsString

import java.sql.Clob; //導入方法依賴的package包/類
@Override
public String getClobAsString(ResultSet rs, int columnIndex) throws SQLException {
	logger.debug("Returning Oracle CLOB as string");
	Clob clob = rs.getClob(columnIndex);
	initializeResourcesBeforeRead(rs.getStatement().getConnection(), clob);
	String retVal = (clob != null ? clob.getSubString(1, (int) clob.length()) : null);
	releaseResourcesAfterRead(rs.getStatement().getConnection(), clob);
	return retVal;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:10,代碼來源:OracleLobHandler.java

示例3: getClobAsString

import java.sql.Clob; //導入方法依賴的package包/類
@Override
public String getClobAsString(ResultSet rs, int columnIndex) throws SQLException {
	logger.debug("Returning CLOB as string");
	if (this.wrapAsLob) {
		Clob clob = rs.getClob(columnIndex);
		return clob.getSubString(1, (int) clob.length());
	}
	else {
		return rs.getString(columnIndex);
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:12,代碼來源:DefaultLobHandler.java

示例4: position

import java.sql.Clob; //導入方法依賴的package包/類
/**
     * Retrieves the character position at which the specified
     * <code>Clob</code> object <code>searchstr</code> appears in this
     * <code>Clob</code> object.  The search begins at position
     * <code>start</code>.
     *
     * @param searchstr the <code>Clob</code> object for which to search
     * @param start the position at which to begin searching; the first
     *              position is 1
     * @return the position at which the <code>Clob</code> object appears
     *              or -1 if it is not present; the first position is 1
     * @exception SQLException if there is an error accessing the
     *            <code>CLOB</code> value
     *
     * @since JDK 1.2, HSQLDB 1.7.2
     */
    public long position(final Clob searchstr,
                         long start) throws SQLException {

        if (searchstr == null) {
            return -1;
        }

        final String ldata = data;
        final long   dlen  = ldata.length();
        final long   sslen = searchstr.length();

// This is potentially much less expensive than materializing a large
// substring from some other vendor's CLOB.  Indeed, we should probably
// do the comparison piecewise, using an in-memory buffer (or temp-files
// when available), if it is detected that the input CLOB is very long.
        if (start > dlen - sslen) {
            return -1;
        }

        // by now, we know sslen and start are both < Integer.MAX_VALUE
        String s;

        if (searchstr instanceof jdbcClob) {
            s = ((jdbcClob) searchstr).data;
        } else {
            s = searchstr.getSubString(1L, (int) sslen);
        }

        final int pos = ldata.indexOf(s, (int) start);

        return (pos < 0) ? -1
                         : pos + 1;
    }
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:50,代碼來源:jdbcClob.java

示例5: position

import java.sql.Clob; //導入方法依賴的package包/類
/**
     * Retrieves the character position at which the specified
     * <code>Clob</code> object <code>searchstr</code> appears in this
     * <code>Clob</code> object.  The search begins at position
     * <code>start</code>.
     *
     * @param searchstr the <code>Clob</code> object for which to search
     * @param start the position at which to begin searching; the first
     *              position is 1
     * @return the position at which the <code>Clob</code> object appears
     *              or -1 if it is not present; the first position is 1
     * @exception SQLException if there is an error accessing the
     *            <code>CLOB</code> value
     *
     * @since JDK 1.2, HSQLDB 1.7.2
     */
    public long position(final Clob searchstr,
                         long start) throws SQLException {

        if (searchstr == null) {
            return -1;
        }

        final String ldata = data;
        final long   dlen  = ldata.length();
        final long   sslen = searchstr.length();

        start--;    //***** FOIRGOT THIS *******

// This is potentially much less expensive than materializing a large
// substring from some other vendor's CLOB.  Indeed, we should probably
// do the comparison piecewise, using an in-memory buffer (or temp-files
// when available), if it is detected that the input CLOB is very long.
        if (start > dlen - sslen) {
            return -1;
        }

        // by now, we know sslen and start are both < Integer.MAX_VALUE
        String s;

        if (searchstr instanceof jdbcClob) {
            s = ((jdbcClob) searchstr).data;
        } else {
            s = searchstr.getSubString(1L, (int) sslen);
        }

        final int pos = ldata.indexOf(s, (int) start);

        return (pos < 0) ? -1
                         : pos + 1;
    }
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:52,代碼來源:jdbcClob.java

示例6: getNullableResult

import java.sql.Clob; //導入方法依賴的package包/類
@Override
public String getNullableResult(ResultSet rs, String columnName) throws SQLException {
	String value = "";
	Clob clob = rs.getClob(columnName);
	if (clob != null) {
		int size = (int) clob.length();
		value = clob.getSubString(1, size);
	}
	return value;
}
 
開發者ID:xsonorg,項目名稱:tangyuan2,代碼行數:11,代碼來源:ClobTypeHandler.java

示例7: position

import java.sql.Clob; //導入方法依賴的package包/類
/**
     * Retrieves the character position at which the specified
     * <code>Clob</code> object <code>searchstr</code> appears in this
     * <code>Clob</code> object.  The search begins at position
     * <code>start</code>.
     *
     * @param searchstr the <code>Clob</code> object for which to search
     * @param start the position at which to begin searching; the first
     *              position is 1
     * @return the position at which the <code>Clob</code> object appears
     *              or -1 if it is not present; the first position is 1
     * @exception SQLException if there is an error accessing the
     *            <code>CLOB</code> value or if start is less than 1
     * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
     * this method
     * @since JDK 1.2, HSQLDB 1.7.2
     */
    public long position(final Clob searchstr,
                         long start) throws SQLException {

        final String ldata = data;

        checkValid(ldata);

        if (start < MIN_POS) {
            throw Util.outOfRangeArgument("start: " + start);
        }

        if (searchstr == null) {
            return -1;
        }

        final long dlen  = ldata.length();
        final long sslen = searchstr.length();

        start--;

// This is potentially much less expensive than materializing a large
// substring from some other vendor's CLOB.  Indeed, we should probably
// do the comparison piecewise, using an in-memory buffer (or temp-files
// when available), if it is detected that the input CLOB is very long.
        if (start > dlen - sslen) {
            return -1;
        }

        // by now, we know sslen and start are both < Integer.MAX_VALUE
        String s;

        if (searchstr instanceof JDBCClob) {
            s = ((JDBCClob) searchstr).data();
        } else {
            s = searchstr.getSubString(1L, (int) sslen);
        }

        final int pos = ldata.indexOf(s, (int) start);

        return (pos < 0) ? -1
                         : pos + 1;
    }
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:60,代碼來源:JDBCClob.java

示例8: readClobRef

import java.sql.Clob; //導入方法依賴的package包/類
/**
 * Actually read a ClobRef instance from the ResultSet and materialize
 * the data either inline or to a file.
 *
 * @param colNum the column of the ResultSet's current row to read.
 * @param r the ResultSet to read from.
 * @return a ClobRef encapsulating the data in this field.
 * @throws IOException if an error occurs writing to the FileSystem.
 * @throws SQLException if an error occurs reading from the database.
 */
public com.cloudera.sqoop.lib.ClobRef readClobRef(int colNum, ResultSet r)
    throws IOException, InterruptedException, SQLException {

  long maxInlineLobLen = conf.getLong(
      MAX_INLINE_LOB_LEN_KEY,
      DEFAULT_MAX_LOB_LENGTH);

  Clob c = r.getClob(colNum);
  if (null == c) {
    return null;
  } else if (c.length() > maxInlineLobLen) {
    // Deserialize large CLOB into separate file.
    long len = c.length();
    LobFile.Writer lobWriter = getClobWriter();

    long recordOffset = lobWriter.tell();
    Reader reader = null;
    Writer w = lobWriter.writeClobRecord(len);
    try {
      reader = c.getCharacterStream();
      copyAll(reader, w);
    } finally {
      if (null != w) {
        w.close();
      }

      if (null != reader) {
        reader.close();
      }

      // Mark the record as finished.
      lobWriter.finishRecord();
    }

    return new com.cloudera.sqoop.lib.ClobRef(
        getRelativePath(lobWriter), recordOffset, len);
  } else {
    // This is a 1-based array.
    return new com.cloudera.sqoop.lib.ClobRef(
        c.getSubString(1, (int) c.length()));
  }
}
 
開發者ID:aliyun,項目名稱:aliyun-maxcompute-data-collectors,代碼行數:53,代碼來源:LargeObjectLoader.java

示例9: clob2String

import java.sql.Clob; //導入方法依賴的package包/類
private static String clob2String(Clob clob) throws Exception {
  return (clob != null ? clob.getSubString(1, (int) clob.length()) : null);
}
 
開發者ID:MiniPa,項目名稱:cjs_ssms,代碼行數:4,代碼來源:TestDB.java


注:本文中的java.sql.Clob.getSubString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。