|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
public interface Blob
SQL BLOB 值在 JavaTM 编程语言中的表示形式(映射关系)。SQL BLOB 是内置类型,它将 Binary Large Object 存储为数据库表的某一行中的一个列值。默认情况下,驱动程序使用 SQL locator(BLOB) 实现 Blob,这意味着 Blob 对象包含一个指向 SQL BLOB 数据而不是数据本身的逻辑指针。Blob 对象在它被创建的事务处理期间有效。
接口 ResultSet、CallableStatement 和 PreparedStatement 中的方法(如 getBlob 和 setBlob)允许编程人员访问 SQL BLOB 值。Blob 接口提供某些方法来获得 SQL BLOB (Binary Large Object) 值的长度、在客户端实现 BLOB 值以及确定 BLOB 值中某一字节样本的位置。此外,此接口还拥有更新 BLOB 值的方法。
| 方法摘要 | |
|---|---|
InputStream |
getBinaryStream()
以流的形式检索此 Blob 实例指定的 BLOB 值。 |
byte[] |
getBytes(long pos,
int length)
以字节数组的形式检索此 Blob 对象表示的全部或部分 BLOB 值。 |
long |
length()
返回由此 Blob 对象指定的 BLOB 值中的字节数。 |
long |
position(Blob pattern,
long start)
检索此 Blob 对象指定的 BLOB 值中 pattern 开始处的字节位置。 |
long |
position(byte[] pattern,
long start)
检索此 Blob 对象表示的 BLOB 值中指定字节数组 pattern 开始处的字节位置。 |
OutputStream |
setBinaryStream(long pos)
检索用于写入此 Blob 对象表示的 BLOB 值的流。 |
int |
setBytes(long pos,
byte[] bytes)
将给定字节数组写入此 Blob 对象表示的 BLOB 值(从位置 pos 处开始),并返回写入的字节数。 |
int |
setBytes(long pos,
byte[] bytes,
int offset,
int len)
将所有或部分给定的 byte 数组写入此 Blob 对象表示的 BLOB 值中,并返回写入的字节数。 |
void |
truncate(long len)
截取此 Blob 对象表示的 BLOB 值,使其长度为 len 个字节。 |
| 方法详细信息 |
|---|
long length()
throws SQLException
Blob 对象指定的 BLOB 值中的字节数。
BLOB 的字节长度
SQLException - 如果访问 BLOB 的长度时发生错误
byte[] getBytes(long pos,
int length)
throws SQLException
Blob 对象表示的全部或部分 BLOB 值。此 byte 数组包含从位置 pos 开始的 length 个连续字节。
pos - 要提取的 BLOB 值中第一个字节的顺序位置;第一个字节位于位置 1 处length - 要复制的连续字节的数量
Blob 对象指定的 BLOB 值中的 length 个连续字节(从位置 pos 处的字节开始)
SQLException - 如果访问 BLOB 值时发生错误setBytes(long, byte[])
InputStream getBinaryStream()
throws SQLException
Blob 实例指定的 BLOB 值。
BLOB 数据的流
SQLException - 如果访问 BLOB 值时发生错误setBinaryStream(long)
long position(byte[] pattern,
long start)
throws SQLException
Blob 对象表示的 BLOB 值中指定字节数组 pattern 开始处的字节位置。对 pattern 的搜索从位置 start 开始。
pattern - 要搜索的字节数组start - 开始搜索的位置;第一个位置是 1
SQLException - 如果访问 BLOB 时发生错误
long position(Blob pattern,
long start)
throws SQLException
Blob 对象指定的 BLOB 值中 pattern 开始处的字节位置。从位置 start 开始搜索。
pattern - 指定要搜索的 BLOB 值的 Blob 对象start - BLOB 值中开始进行搜索的位置;第一个位置是 1
SQLException - 如果访问 BLOB 值时发生错误
int setBytes(long pos,
byte[] bytes)
throws SQLException
Blob 对象表示的 BLOB 值(从位置 pos 处开始),并返回写入的字节数。
pos - BLOB 对象开始进行写入操作的位置bytes - 要写入此 Blob 对象表示的 BLOB 值中的字节数组
SQLException - 如果访问 BLOB 值时发生错误getBytes(long, int)
int setBytes(long pos,
byte[] bytes,
int offset,
int len)
throws SQLException
byte 数组写入此 Blob 对象表示的 BLOB 值中,并返回写入的字节数。写入操作从 BLOB 值中的位置 pos 处开始;写入给定字节数组中的 len 个字节。
pos - BLOB 对象开始进行写入操作的位置bytes - 要写入此 BLOB 对象中的字节数组offset - 数组 bytes 中的偏移量,从此处开始读取要设置的字节len - 字节数组 bytes 中写入 BLOB 值的字节数
SQLException - 如果访问 BLOB 值时发生错误getBytes(long, int)
OutputStream setBinaryStream(long pos)
throws SQLException
Blob 对象表示的 BLOB 值的流。该流从位置 pos 处开始。
pos - BLOB 值中开始进行写入操作的位置
java.io.OutputStream 对象
SQLException - 如果访问 BLOB 值时发生错误getBinaryStream()
void truncate(long len)
throws SQLException
Blob 对象表示的 BLOB 值,使其长度为 len 个字节。
len - 此 Blob 对象表示的 BLOB 值将被截取的字节长度
SQLException - 如果访问 BLOB 值时发生错误
|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。