Most visited

Recently visited

Added in API level 1

Clob

public interface Clob

java.sql.Clob
Known Indirect Subclasses


Java TM编程语言中用于SQL CLOB类型的映射。 SQL CLOB是一种内置类型,它将字符大对象作为列值存储在数据库表的一行中。 默认情况下,驱动程序使用SQL locator(CLOB)实现Clob对象,这意味着Clob对象包含一个指向SQL CLOB数据的逻辑指针,而不是数据本身。 一个Clob对象在创建它的事务期间有效。

Clob接口提供了获取SQL CLOB (字符大对象)值的长度的方法,用于在客户端上实现CLOB值,并在CLOB值内搜索子字符串或CLOB对象。 方法在接口ResultSetCallableStatement ,并PreparedStatement ,如getClobsetClob允许编程人员访问SQL CLOB值。 此外,该接口还具有更新CLOB值的方法。

如果JDBC驱动程序支持数据类型,则必须完全实现 Clob接口上的所有方法。

Summary

Public methods

abstract void free()

此方法释放 Clob对象并释放资源所拥有的资源。

abstract InputStream getAsciiStream()

以ascii流的 CLOB检索此 Clob对象指定的 CLOB值。

abstract Reader getCharacterStream()

java.io.Reader对象(或字符流)的形式检索此 Clob对象指定的 CLOB值。

abstract Reader getCharacterStream(long pos, long length)

返回包含 Clob部分值的 Reader对象,从pos指定的字符开始,长度为length个字符。

abstract String getSubString(long pos, int length)

检索此 Clob对象指定的 CLOB值中指定子字符串的副本。

abstract long length()

检索此 Clob对象指定的 CLOB值中的字符数。

abstract long position(String searchstr, long start)

检索指定的子字符串 searchstr在此 Clob对象表示的SQL CLOB值中出现的字符位置。

abstract long position(Clob searchstr, long start)

检索指定的 Clob对象 searchstr在此 Clob对象中出现的字符位置。

abstract OutputStream setAsciiStream(long pos)

CLOB位置开始,检索用于将Ascii字符写入到此 Clob对象所表示的 CLOB值的 pos

abstract Writer setCharacterStream(long pos)

检索要用于将Unicode字符流写入 Clob对象表示的 CLOB值的流,位置为 pos

abstract int setString(long pos, String str, int offset, int len)

写入 len的字符 str ,起始于字符 offsetCLOB值,这 Clob表示。

abstract int setString(long pos, String str)

写入给定的Java StringCLOB值,这 Clob对象表示在该位置 pos

abstract void truncate(long len)

截断此 Clob指定的 CLOB值的长度为 len字符。

Public methods

free

Added in API level 9
void free ()

这种方法释放了Clob对象并释放它拥有的资源。 调用free方法后,该对象无效。

free之后,任何尝试调用除free以外的方法free将导致SQLException被抛出。 如果free被多次调用,在后续调用free被视为无操作。

Throws
SQLException if an error occurs releasing the Clob's resources
SQLFeatureNotSupportedException if the JDBC driver does not support this method

getAsciiStream

Added in API level 1
InputStream getAsciiStream ()

以ascii流的 CLOB检索此 Clob对象指定的 CLOB值。

Returns
InputStream a java.io.InputStream object containing the CLOB data
Throws
SQLException if there is an error accessing the CLOB value
SQLFeatureNotSupportedException if the JDBC driver does not support this method

也可以看看:

getCharacterStream

Added in API level 1
Reader getCharacterStream ()

java.io.Reader对象(或以字符流形式)检索此 Clob对象指定的 CLOB值。

Returns
Reader a java.io.Reader object containing the CLOB data
Throws
SQLException if there is an error accessing the CLOB value
SQLFeatureNotSupportedException if the JDBC driver does not support this method

也可以看看:

getCharacterStream

Added in API level 9
Reader getCharacterStream (long pos, 
                long length)

返回包含部分 Clob值的 Reader对象,从pos指定的字符开始,长度为length个字符。

Parameters
pos long: the offset to the first character of the partial value to be retrieved. The first character in the Clob is at position 1.
length long: the length in characters of the partial value to be retrieved.
Returns
Reader Reader through which the partial Clob value can be read.
Throws
SQLException if pos is less than 1 or if pos is greater than the number of characters in the Clob or if pos + length is greater than the number of characters in the Clob
SQLFeatureNotSupportedException if the JDBC driver does not support this method

getSubString

Added in API level 1
String getSubString (long pos, 
                int length)

检索此Clob对象指定的CLOB值中指定子字符串的副本。 子字符串从位置pos开始,最多有length个连续字符。

Parameters
pos long: the first character of the substring to be extracted. The first character is at position 1.
length int: the number of consecutive characters to be copied; the value for length must be 0 or greater
Returns
String a String that is the specified substring in the CLOB value designated by this Clob object
Throws
SQLException if there is an error accessing the CLOB value; if pos is less than 1 or length is less than 0
SQLFeatureNotSupportedException if the JDBC driver does not support this method

length

Added in API level 1
long length ()

检索此 Clob对象指定的 CLOB值中的字符数。

Returns
long length of the CLOB in characters
Throws
SQLException if there is an error accessing the length of the CLOB value
SQLFeatureNotSupportedException if the JDBC driver does not support this method

position

Added in API level 1
long position (String searchstr, 
                long start)

检索指定的子字符串searchstr出现在由此Clob对象表示的SQL CLOB值中的字符位置。 搜索从位置start开始。

Parameters
searchstr String: the substring for which to search
start long: the position at which to begin searching; the first position is 1
Returns
long the position at which the substring appears or -1 if it is not present; the first position is 1
Throws
SQLException if there is an error accessing the CLOB value or if pos is less than 1
SQLFeatureNotSupportedException if the JDBC driver does not support this method

position

Added in API level 1
long position (Clob searchstr, 
                long start)

在检索该指定的字符位置Clob对象searchstr出现在此Clob对象。 搜索从位置start开始。

Parameters
searchstr Clob: the Clob object for which to search
start long: the position at which to begin searching; the first position is 1
Returns
long the position at which the Clob object appears or -1 if it is not present; the first position is 1
Throws
SQLException if there is an error accessing the CLOB value or if start is less than 1
SQLFeatureNotSupportedException if the JDBC driver does not support this method

setAsciiStream

Added in API level 1
OutputStream setAsciiStream (long pos)

CLOB位置开始,检索用于将Ascii字符写入到Clob对象所表示的CLOB值的pos 写入流中的字符将覆盖从位置pos开始的Clob对象中的现有字符。 如果年底Clob ,而写入字符到流达到的值,那么长度Clob值将增加,以容纳额外的字符。

注意:如果为pos指定的值大于CLOB值的长度+ 1,则行为未定义。 某些JDBC驱动程序可能会抛出SQLException而其他驱动程序可能会支持此操作。

Parameters
pos long: the position at which to start writing to this CLOB object; The first position is 1
Returns
OutputStream the stream to which ASCII encoded characters can be written
Throws
SQLException if there is an error accessing the CLOB value or if pos is less than 1
SQLFeatureNotSupportedException if the JDBC driver does not support this method

也可以看看:

setCharacterStream

Added in API level 1
Writer setCharacterStream (long pos)

检索用于将Unicode字符流写入到Clob对象表示的CLOB值的流,位置为pos 写入流的字符将覆盖在现有的字符Clob在位置对象起始pos 如果年底Clob ,而写入字符到流达到的值,那么长度Clob值将增加,以容纳额外的字符。

注意:如果为pos指定的值大于CLOB值的长度+ 1,则行为未定义。 某些JDBC驱动程序可能会抛出SQLException而其他驱动程序可能会支持此操作。

Parameters
pos long: the position at which to start writing to the CLOB value; The first position is 1
Returns
Writer a stream to which Unicode encoded characters can be written
Throws
SQLException if there is an error accessing the CLOB value or if pos is less than 1
SQLFeatureNotSupportedException if the JDBC driver does not support this method

也可以看看:

setString

Added in API level 1
int setString (long pos, 
                String str, 
                int offset, 
                int len)

写入len的字符str ,起始于字符offsetCLOB值,这Clob表示。 字符串将覆盖在现有的字符Clob在位置对象起始pos 如果年底Clob一边写定的字符串是否达到了值,那么长度Clob值将增加,以容纳额外的字符。

注意:如果为pos指定的值大于CLOB值的长度+ 1,则行为未定义。 某些JDBC驱动程序可能会抛出SQLException而其他驱动程序可能会支持此操作。

Parameters
pos long: the position at which to start writing to this CLOB object; The first position is 1
str String: the string to be written to the CLOB value that this Clob object represents
offset int: the offset into str to start reading the characters to be written
len int: the number of characters to be written
Returns
int the number of characters written
Throws
SQLException if there is an error accessing the CLOB value or if pos is less than 1
SQLFeatureNotSupportedException if the JDBC driver does not support this method

setString

Added in API level 1
int setString (long pos, 
                String str)

写入给定的Java StringCLOB值,这Clob对象表示在该位置pos 字符串将覆盖在现有的字符Clob在位置对象起始pos 如果年底Clob一边写定的字符串是否达到了值,那么长度Clob值将增加,以容纳额外的字符。

注意:如果为pos指定的值大于CLOB值的长度+ 1,则行为未定义。 某些JDBC驱动程序可能会抛出SQLException而其他驱动程序可能会支持此操作。

Parameters
pos long: the position at which to start writing to the CLOB value that this Clob object represents; The first position is 1
str String: the string to be written to the CLOB value that this Clob designates
Returns
int the number of characters written
Throws
SQLException if there is an error accessing the CLOB value or if pos is less than 1
SQLFeatureNotSupportedException if the JDBC driver does not support this method

truncate

Added in API level 1
void truncate (long len)

截断此 Clob指定的 CLOB值,其长度为 len字符。

注意:如果为pos指定的值大于CLOB值的长度+ 1,则行为未定义。 某些JDBC驱动程序可能会抛出SQLException而其他驱动程序可能会支持此操作。

Parameters
len long: the length, in characters, to which the CLOB value should be truncated
Throws
SQLException if there is an error accessing the CLOB value or if len is less than 0
SQLFeatureNotSupportedException if the JDBC driver does not support this method

Hooray!