|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
public interface Clob
SQL 类型 CLOB 在 JavaTM 编程语言中的映射关系。SQL CLOB 是内置类型,它将字符大对象 (Character Large Object) 存储为数据库表某一行中的一个列值。默认情况下,驱动程序使用 SQL locator(CLOB) 实现 Clob 对象,这意味着 CLOB 对象包含一个指向 SQL CLOB 数据的逻辑指针而不是数据本身。Clob 对象在它被创建的事务处理期间有效。
CLOB 接口提供一些方法来获取 SQL CLOB (Character Large Object) 值长度、在客户端实现 CLOB 值以及搜索 CLOB 值中的子字符串或 CLOB 对象。接口 ResultSet、CallableStatement 和 PreparedStatement 中的方法(如 getClob 和 setClob)允许编程人员访问 SQL CLOB 值。此外,此接口还拥有更新 CLOB 值的方法。
如果 JDBC 驱动程序支持该数据类型,则必须完全实现 Clob 接口上的所有方法。
| 方法摘要 | |
|---|---|
void |
free()
此方法释放 Clob 对象以及它所占用的资源。 |
InputStream |
getAsciiStream()
以 ascii 流形式获取此 Clob 对象指定的 CLOB 值。 |
Reader |
getCharacterStream()
以 java.io.Reader 对象形式(或字符流形式)获取此 Clob 对象指定的 CLOB 值。 |
Reader |
getCharacterStream(long pos,
long length)
返回包含部分 Clob 值的 Reader 对象,该值从 pos 指定的字符开始,长度为 length 个字符。 |
String |
getSubString(long pos,
int length)
获取此 Clob 对象指定的 CLOB 值中指定子字符串的副本。 |
long |
length()
获取此 Clob 对象指定的 CLOB 值中的字符数。 |
long |
position(Clob searchstr,
long start)
获取此 Clob 对象中指定的 Clob 对象 searchstr 出现的字符位置。 |
long |
position(String searchstr,
long start)
获取此 Clob 对象表示的 SQL CLOB 值中指定子字符串 searchstr 出现的字符位置。 |
OutputStream |
setAsciiStream(long pos)
获取用于将 Ascii 字符写入此 Clob 对象表示的 Clob 值中的流,从位置 pos 处开始。 |
Writer |
setCharacterStream(long pos)
获取用于将 Unicode 字符流写入此 Clob 对象表示的 CLOB 值中(位置 pos 处)的流。 |
int |
setString(long pos,
String str)
在位置 pos 处将给定 Java String 写入此 Clob 对象指定的 CLOB 值中。 |
int |
setString(long pos,
String str,
int offset,
int len)
将 str 的 len 个字符(从字符 offset 开始)写入此 Clob 表示的 CLOB 值中。 |
void |
truncate(long len)
截取此 Clob 指定的 CLOB 值,使其长度为 len 个字符。 |
| 方法详细信息 |
|---|
long length()
throws SQLException
Clob 对象指定的 CLOB 值中的字符数。
CLOB 的字符长度
SQLException - 如果访问 CLOB 值的长度时发生错误
SQLFeatureNotSupportedException - 如果 JDBC 驱动程序不支持此方法
String getSubString(long pos,
int length)
throws SQLException
Clob 对象指定的 CLOB 值中指定子字符串的副本。子字符串开始于位置 pos 处,有 length 个连续字符。
pos - 要提取的子字符串的第一个字符。第一个字符位于位置 1 处。length - 要复制的连续字符的数量;length 的值必须大于等于 0
String,它是由此 Clob 对象指定的 CLOB 值中的指定子字符串
SQLException - 如果访问 CLOB 值时发生错误;如果 pos 小于 1 或者 length 小于 0
SQLFeatureNotSupportedException - 如果 JDBC 驱动程序不支持此方法
Reader getCharacterStream()
throws SQLException
java.io.Reader 对象形式(或字符流形式)获取此 Clob 对象指定的 CLOB 值。
CLOB 数据的 java.io.Reader 对象
SQLException - 如果访问 CLOB 值时发生错误
SQLFeatureNotSupportedException - 如果 JDBC 驱动程序不支持此方法setCharacterStream(long)
InputStream getAsciiStream()
throws SQLException
Clob 对象指定的 CLOB 值。
CLOB 数据的 java.io.InputStream 对象
SQLException - 如果访问 CLOB 值时发生错误
SQLFeatureNotSupportedException - 如果 JDBC 驱动程序不支持此方法setAsciiStream(long)
long position(String searchstr,
long start)
throws SQLException
Clob 对象表示的 SQL CLOB 值中指定子字符串 searchstr 出现的字符位置。从位置 start 开始搜索。
searchstr - 要搜索的子字符串start - 开始搜索的位置;第一个位置是 1
SQLException - 如果访问 CLOB 值时发生错误,或者 pos 小于 1
SQLFeatureNotSupportedException - 如果 JDBC 驱动程序不支持此方法
long position(Clob searchstr,
long start)
throws SQLException
Clob 对象中指定的 Clob 对象 searchstr 出现的字符位置。从位置 start 开始搜索。
searchstr - 要搜索的 Clob 对象start - 开始搜索的位置;第一个位置是 1
Clob 对象出现的位置;如果没有出现,则返回 -1;第一个位置是 1
SQLException - 如果访问 CLOB 值时发生错误,或者 start 小于 1
SQLFeatureNotSupportedException - 如果 JDBC 驱动程序不支持此方法
int setString(long pos,
String str)
throws SQLException
pos 处将给定 Java String 写入此 Clob 对象指定的 CLOB 值中。该字符串将从位置 pos 开始重写 Clob 对象中的现有字节。如果在写入给定字符串时到达 Clob 值的末尾,则将增加 Clob 值的长度,以容纳额外的字符。
注:如果为 pos 指定的值大于 CLOB 值的长度+1,则行为是不确定的。一些 JDBC 驱动程序可能抛出 SQLException,而另一些驱动程序可能支持此操作。
pos - 开始写入此 Clob 对象表示的 CLOB 值的位置;第一个位置是 1str - 要写入此 Clob 指定的 CLOB 值中的字符串
SQLException - 如果访问 CLOB 值时发生错误,或者 pos 小于 1
SQLFeatureNotSupportedException - 如果 JDBC 驱动程序不支持此方法
int setString(long pos,
String str,
int offset,
int len)
throws SQLException
str 的 len 个字符(从字符 offset 开始)写入此 Clob 表示的 CLOB 值中。该字符串将从位置 pos 开始重写 Clob 对象中的现有字节。如果在写入给定字符串时到达 Clob 值的末尾,则将增加 Clob 值的长度,以容纳额外的字符。
注:如果为 pos 指定的值大于 CLOB 值的长度+1,则行为是不确定的。一些 JDBC 驱动程序可能抛出 SQLException,而另一些驱动程序可能支持此操作。
pos - 开始写入此 CLOB 对象的位置;第一个位置是 1str - 要写入此 Clob 对象表示的 CLOB 值中的字符串offset - str 中开始读取要写入字符的偏移量len - 要写入的字符数
SQLException - 如果访问 CLOB 值时发生错误,或者 pos 小于 1
SQLFeatureNotSupportedException - 如果 JDBC 驱动程序不支持此方法
OutputStream setAsciiStream(long pos)
throws SQLException
Clob 对象表示的 Clob 值中的流,从位置 pos 处开始。写入流中的字符将从位置 pos 开始重写 Clob 对象中的现有字节。如果在将字符写入流中时到达 Clob 值的末尾,则将增加 Clob 值的长度,以容纳额外的字符。
注:如果为 pos 指定的值大于 CLOB 值的长度+1,则行为是不确定的。一些 JDBC 驱动程序可能抛出 SQLException,而另一些驱动程序可能支持此操作。
pos - 开始写入此 CLOB 对象中的位置;第一个位置是 1
SQLException - 如果访问 CLOB 值时发生错误,或者 pos 小于 1
SQLFeatureNotSupportedException - 如果 JDBC 驱动程序不支持此方法#getBinaryStream
Writer setCharacterStream(long pos)
throws SQLException
Clob 对象表示的 CLOB 值中(位置 pos 处)的流。写入流中的字符将从位置 pos 开始重写 Clob 对象中的现有字节。如果在将字符写入流中时到达 Clob 值的末尾,则将增加 Clob 值的长度,以容纳额外的字符。
注:如果为 pos 指定的值大于 CLOB 值的长度+1,则行为是不确定的。一些 JDBC 驱动程序可能抛出 SQLException,而另一些驱动程序可能支持此操作。
pos - 开始写入 CLOB 值中的位置;第一个位置是 1
SQLException - 如果访问 CLOB 值时发生错误,或者 pos 小于 1
SQLFeatureNotSupportedException - 如果 JDBC 驱动程序不支持此方法getCharacterStream()
void truncate(long len)
throws SQLException
Clob 指定的 CLOB 值,使其长度为 len 个字符。
注:如果为 pos 指定的值大于 CLOB 值的长度+1,则行为是不确定的。一些 JDBC 驱动程序可能抛出 SQLException,而另一些驱动程序可能支持此操作。
len - CLOB 值应被截取的字符长度
SQLException - 如果访问 CLOB 值时发生错误,或者 len 小于 0
SQLFeatureNotSupportedException - 如果 JDBC 驱动程序不支持此方法
void free()
throws SQLException
Clob 对象以及它所占用的资源。调用 free 方法后,该对象无效。
在调用 free 方法之后,试图调用 free 之外的方法将导致抛出 SQLException。如果多次调用 free,则对 free 的后续调用被视为无操作 (no-op)。
SQLException - 如果释放 Clob 的资源时发生错误
SQLFeatureNotSupportedException - 如果 JDBC 驱动程序不支持此方法
Reader getCharacterStream(long pos,
long length)
throws SQLException
Clob 值的 Reader 对象,该值从 pos 指定的字符开始,长度为 length 个字符。
pos - 将获取的部分值第一个字符的偏移量。Clob 中的第一个字符在位置 1 处。length - 要获取的部分值的字符长度。
Reader,可以通过它来读取部分 Clob 值。
SQLException - 如果 pos 小于 1,或者 pos 大于 Clob 中的字符数,或者 pos + length 大于 Clob 中的字符数
SQLFeatureNotSupportedException - 如果 JDBC 驱动程序不支持此方法
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。