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
对象。 方法在接口ResultSet
, CallableStatement
,并PreparedStatement
,如getClob
和setClob
允许编程人员访问SQL CLOB
值。 此外,该接口还具有更新CLOB
值的方法。
如果JDBC驱动程序支持数据类型,则必须完全实现 Clob
接口上的所有方法。
Public methods |
|
---|---|
abstract void |
free() 此方法释放 |
abstract InputStream |
getAsciiStream() 以ascii流的 |
abstract Reader |
getCharacterStream() 以 |
abstract Reader |
getCharacterStream(long pos, long length) 返回包含 |
abstract String |
getSubString(long pos, int length) 检索此 |
abstract long |
length() 检索此 |
abstract long |
position(String searchstr, long start) 检索指定的子字符串 |
abstract long |
position(Clob searchstr, long start) 检索指定的 |
abstract OutputStream |
setAsciiStream(long pos) 从 |
abstract Writer |
setCharacterStream(long pos) 检索要用于将Unicode字符流写入 |
abstract int |
setString(long pos, String str, int offset, int len) 写入 |
abstract int |
setString(long pos, String str) 写入给定的Java |
abstract void |
truncate(long len) 截断此 |
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 |
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 |
也可以看看:
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 |
也可以看看:
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 |
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 |
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 |
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 |
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 |
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 |
也可以看看:
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 |
也可以看看:
int setString (long pos, String str, int offset, int len)
写入len
的字符str
,起始于字符offset
到CLOB
值,这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 |
int setString (long pos, String str)
写入给定的Java String
到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 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 |
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 |