Package java.sql
Interface Clob
- All Known Subinterfaces:
NClob
public interface Clob
A Java interface mapping for the SQL CLOB type.
An SQL CLOB type stores a large array of characters as the value in a
column of a database.
The java.sql.Clob interface provides methods for setting and
retrieving data in the Clob, for querying Clob data length,
for searching for data within the Clob.
-
Method Summary
Modifier and Type Method Description voidfree()Frees any resources held by this clob.InputStreamgetAsciiStream()Gets the value of thisClobobject as an ASCII stream.ReadergetCharacterStream()Gets the data of thisClobobject in ajava.io.Reader.ReadergetCharacterStream(long pos, long length)Returns aReaderthat readslengthcharacters from this clob, starting at 1-based offset {code pos}.StringgetSubString(long pos, int length)Gets a copy of a specified substring in thisClob.longlength()Retrieves the number of characters in thisClobobject.longposition(String searchstr, long start)Retrieves the character position at which a specified substring appears in thisClobobject.longposition(Clob searchstr, long start)Retrieves the character position at which a specifiedClobobject appears in thisClobobject.OutputStreamsetAsciiStream(long pos)Retrieves a stream which can be used to write Ascii characters to thisClobobject, starting at specified position.WritersetCharacterStream(long pos)Retrieves a stream which can be used to write a stream of unicode characters to thisClobobject, at a specified position.intsetString(long pos, String str)Writes a given Java String to thisClobobject at a specified position.intsetString(long pos, String str, int offset, int len)Writeslencharacters of a string, starting at a specified character offset, to thisClob.voidtruncate(long len)Truncates thisClobafter the specified number of characters.
-
Method Details
-
getAsciiStream
Gets the value of thisClobobject as an ASCII stream.- Returns:
- an ASCII
InputStreamgiving access to theClobdata. - Throws:
SQLException- if an error occurs accessing theClob.
-
getCharacterStream
Gets the data of thisClobobject in ajava.io.Reader.- Returns:
- a character stream Reader object giving access to the
Clobdata. - Throws:
SQLException- if an error occurs accessing theClob.
-
getSubString
Gets a copy of a specified substring in thisClob.- Parameters:
pos- the index of the start of the substring in theClob.length- the length of the data to retrieve.- Returns:
- A string containing the requested data.
- Throws:
SQLException- if an error occurs accessing theClob.
-
length
Retrieves the number of characters in thisClobobject.- Returns:
- a long value with the number of character in this
Clob. - Throws:
SQLException- if an error occurs accessing theClob.
-
position
Retrieves the character position at which a specifiedClobobject appears in thisClobobject.- Parameters:
searchstr- the specifiedClobto search for.start- the position within thisClobto start the search- Returns:
- a long value with the position at which the specified
Cloboccurs within thisClob. - Throws:
SQLException- if an error occurs accessing theClob.
-
position
Retrieves the character position at which a specified substring appears in thisClobobject.- Parameters:
searchstr- the string to search for.start- the position at which to start the search within thisClob.- Returns:
- a long value with the position at which the specified string
occurs within this
Clob. - Throws:
SQLException- if an error occurs accessing theClob.
-
setAsciiStream
Retrieves a stream which can be used to write Ascii characters to thisClobobject, starting at specified position.- Parameters:
pos- the position at which to start the writing.- Returns:
- an OutputStream which can be used to write ASCII characters to
this
Clob. - Throws:
SQLException- if an error occurs accessing theClob.
-
setCharacterStream
Retrieves a stream which can be used to write a stream of unicode characters to thisClobobject, at a specified position.- Parameters:
pos- the position at which to start the writing.- Returns:
- a Writer which can be used to write unicode characters to this
Clob. - Throws:
SQLException- if an error occurs accessing theClob.
-
setString
Writes a given Java String to thisClobobject at a specified position.- Parameters:
pos- the position at which to start the writing.str- the string to write.- Returns:
- the number of characters written.
- Throws:
SQLException- if an error occurs accessing theClob.
-
setString
Writeslencharacters of a string, starting at a specified character offset, to thisClob.- Parameters:
pos- the position at which to start the writing.str- the String to write.offset- the offset withinstrto start writing from.len- the number of characters to write.- Returns:
- the number of characters written.
- Throws:
SQLException- if an error occurs accessing theClob.
-
truncate
Truncates thisClobafter the specified number of characters.- Parameters:
len- the length in characters giving the place to truncate thisClob.- Throws:
SQLException- if an error occurs accessing theClob.
-
free
Frees any resources held by this clob. Afterfreeis called, calling method other thanfreewill throwSQLException(callingfreerepeatedly will do nothing).- Throws:
SQLException
-
getCharacterStream
Returns aReaderthat readslengthcharacters from this clob, starting at 1-based offset {code pos}.- Throws:
SQLException
-