java.applet

java.awt

java.awt.color

java.awt.datatransfer

java.awt.dnd

java.awt.event

java.awt.font

java.awt.geom

java.awt.im

java.awt.im.spi

java.awt.image

java.awt.image.renderable

java.awt.print

java.beans

java.beans.beancontext

java.io

java.lang

java.lang.annotation

java.lang.instrument

java.lang.management

java.lang.ref

java.lang.reflect

java.math

java.net

java.nio

java.nio.channels

java.nio.channels.spi

java.nio.charset

java.nio.charset.spi

java.rmi

java.rmi.activation

java.rmi.dgc

java.rmi.registry

java.rmi.server

java.security

java.security.acl

java.security.cert

java.security.interfaces

java.security.spec

java.sql

java.text

java.util

java.util.concurrent

java.util.concurrent.atomic

java.util.concurrent.locks

java.util.jar

java.util.logging

java.util.prefs

java.util.regex

java.util.zip

javax.accessibility

javax.activity

javax.crypto

javax.crypto.interfaces

javax.crypto.spec

javax.imageio

javax.imageio.event

javax.imageio.metadata

javax.imageio.plugins.bmp

javax.imageio.plugins.jpeg

javax.imageio.spi

javax.imageio.stream

javax.management

javax.management.loading

javax.management.modelmbean

javax.management.monitor

javax.management.openmbean

javax.management.relation

javax.management.remote

javax.management.remote.rmi

javax.management.timer

javax.naming

javax.naming.directory

javax.naming.event

javax.naming.ldap

javax.naming.spi

javax.net

javax.net.ssl

javax.print

javax.print.attribute

javax.print.attribute.standard

javax.print.event

javax.rmi

javax.rmi.CORBA

javax.rmi.ssl

javax.security.auth

javax.security.auth.callback

javax.security.auth.kerberos

javax.security.auth.login

javax.security.auth.spi

javax.security.auth.x500

javax.security.cert

javax.security.sasl

javax.sound.midi

javax.sound.midi.spi

javax.sound.sampled

javax.sound.sampled.spi

javax.sql

javax.sql.rowset

javax.sql.rowset.serial

javax.sql.rowset.spi

javax.swing

javax.swing.border

javax.swing.colorchooser

javax.swing.event

javax.swing.filechooser

javax.swing.plaf

javax.swing.plaf.basic

javax.swing.plaf.metal

javax.swing.plaf.multi

javax.swing.plaf.synth

javax.swing.table

javax.swing.text

javax.swing.text

javax.swing.text.parser

javax.swing.text.rtf

javax.swing.tree

javax.swing.undo

javax.transaction

javax.transaction.xa

javax.xml

javax.xml.datatype

javax.xml.namespace

javax.xml.parsers

javax.xml.transform

javax.xml.transform.dom

javax.xml.transform.sax

javax.xml.transform.stream

javax.xml.validation

javax.xml.xpath

org.ietf.jgss

org.omg.CORBA

org.omg.CORBA_2_3

org.omg.CORBA_2_3.portable

org.omg.CORBA.DynAnyPackage

org.omg.CORBA.ORBPackage

org.omg.CORBA.portable

org.omg.CORBA.TypeCodePackage

org.omg.CosNaming

org.omg.CosNaming.NamingContextExtPackage

org.omg.CosNaming.NamingContextPackage

org.omg.Dynamic

org.omg.DynamicAny

org.omg.DynamicAny.DynAnyFactoryPackage

org.omg.DynamicAny.DynAnyPackage

org.omg.IOP

org.omg.IOP.CodecFactoryPackage

org.omg.IOP.CodecPackage

org.omg.Messaging

org.omg.PortableInterceptor

org.omg.PortableInterceptor.ORBInitInfoPackage

org.omg.PortableServer

org.omg.PortableServer.CurrentPackage

org.omg.PortableServer.POAManagerPackage

org.omg.PortableServer.POAPackage

org.omg.PortableServer.portable

org.omg.PortableServer.ServantLocatorPackage

org.omg.SendingContext

org.omg.stub.java.rmi

org.w3c.dom

org.w3c.dom.bootstrap

org.w3c.dom.events

org.w3c.dom.ls

org.xml.sax

org.xml.sax.ext

org.xml.sax.helpers

allclasses-frame

allclasses-noframe

constant-values

deprecated-list

help-doc

JavaTM 2 Platform
Standard Ed. 5.0

java.sql
接口 Clob

所有已知实现类:
SerialClob

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 对象。接口 ResultSetCallableStatementPreparedStatement 中的方法(如 getClobsetClob)允许编程人员访问 SQL CLOB 值。此外,此接口还拥有更新 CLOB 值的方法。

从以下版本开始:
1.2

方法摘要
 InputStream getAsciiStream()
          以 ascii 流形式检索由此 Clob 对象指定的 CLOB 值。
 Reader getCharacterStream()
          以 java.io.Reader 对象形式(或字符流形式)检索此 Clob 对象指定的 CLOB 值。
 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)
          将 strlen 个字符写入此 Clob 表示的 CLOB 值中,从字符 offset 开始。
 void truncate(long len)
          截取此 Clob 指定的 CLOB 值,使其长度为 len 个字符。
 

方法详细信息

length

long length()
            throws SQLException
检索此 Clob 对象指定的 CLOB 值中的字符数。

返回:
CLOB 的字符长度
抛出:
SQLException - 如果访问 CLOB 值的长度时发生错误
从以下版本开始:
1.2

getSubString

String getSubString(long pos,
                    int length)
                    throws SQLException
检索此 Clob 对象指定的 CLOB 值中指定子字符串的副本。子字符串开始于位置 pos 处,有 length 个连续字符。

参数:
pos - 要提取的子字符串的第一个字符。第一个字符位于位置 1 处。
length - 要复制的连续字符的数量
返回:
一个 String,它是由此 Clob 对象指定的 CLOB 值中的指定子字符串
抛出:
SQLException - 如果访问 CLOB 值时发生错误
从以下版本开始:
1.2

getCharacterStream

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

返回:
包含 CLOB 数据的 java.io.Reader 对象
抛出:
SQLException - 如果访问 CLOB 值时发生错误
从以下版本开始:
1.2
另请参见:
setCharacterStream(long)

getAsciiStream

InputStream getAsciiStream()
                           throws SQLException
以 ascii 流形式检索由此 Clob 对象指定的 CLOB 值。

返回:
包含 CLOB 数据的 java.io.InputStream 对象
抛出:
SQLException - 如果访问 CLOB 值时发生错误
从以下版本开始:
1.2
另请参见:
setAsciiStream(long)

position

long position(String searchstr,
              long start)
              throws SQLException
检索由此 Clob 对象表示的 SQL CLOB 值中指定子字符串 searchstr 出现的字符位置。从位置 start 开始搜索。

参数:
searchstr - 要搜索的子字符串
start - 开始搜索的位置;第一个位置是 1
返回:
子字符串出现的位置,如果子字符串没有出现,则返回 -1;第一个位置是 1
抛出:
SQLException - 如果访问 CLOB 值时发生错误
从以下版本开始:
1.2

position

long position(Clob searchstr,
              long start)
              throws SQLException
检索此 Clob 对象中指定的 Clob 对象 searchstr 出现的字符位置。从位置 start 开始搜索。

参数:
searchstr - 要搜索的 Clob 对象
start - 开始搜索的位置;第一个位置是 1
返回:
Clob 对象出现的位置,如果子字符串没有出现,则返回 -1;第一个位置是 1
抛出:
SQLException - 如果访问 CLOB 值时发生错误
从以下版本开始:
1.2

setString

int setString(long pos,
              String str)
              throws SQLException
在位置 pos 处将给定 Java String 写入此 Clob 对象指定的 CLOB 值中。

参数:
pos - 开始写入此 Clob 对象表示的 CLOB 值的位置
str - 要写入此 Clob 指定的 CLOB 值中的字符串
返回:
写入的字符数
抛出:
SQLException - 如果访问 CLOB 值时发生错误
从以下版本开始:
1.4

setString

int setString(long pos,
              String str,
              int offset,
              int len)
              throws SQLException
strlen 个字符写入此 Clob 表示的 CLOB 值中,从字符 offset 开始。

参数:
pos - 开始写入此 CLOB 对象的位置
str - 要写入此 Clob 对象表示的 CLOB 值中的字符串
offset - str 中开始读取要写入字符的偏移量
len - 要写入的字符数
返回:
写入的字符数
抛出:
SQLException - 如果访问 CLOB 值时发生错误
从以下版本开始:
1.4

setAsciiStream

OutputStream setAsciiStream(long pos)
                            throws SQLException
检索用于将 Ascii 字符写入此 Clob 对象表示的 Clob 值中的流,从位置 pos 处开始。

参数:
pos - 开始写入此 CLOB 对象的位置
返回:
可将 ASCII 编码字符写入其中的流
抛出:
SQLException - 如果访问 CLOB 值时发生错误
从以下版本开始:
1.4
另请参见:
getAsciiStream()

setCharacterStream

Writer setCharacterStream(long pos)
                          throws SQLException
检索用于将 Unicode 字符流写入此 Clob 对象表示的 CLOB 值中(位置 pos 处)的流。

参数:
pos - 开始写入 CLOB 值中的位置
返回:
可将 Unicode 编码字符写入其中的流
抛出:
SQLException - 如果访问 CLOB 值时发生错误
从以下版本开始:
1.4
另请参见:
getCharacterStream()

truncate

void truncate(long len)
              throws SQLException
截取此 Clob 指定的 CLOB 值,使其长度为 len 个字符。

参数:
len - CLOB 值应被截取的字节长度
抛出:
SQLException - 如果访问 CLOB 值时发生错误
从以下版本开始:
1.4

JavaTM 2 Platform
Standard Ed. 5.0

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java 2 SDK SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策