Package java.sql
Interface Clob
-
- All Known Subinterfaces:
NClob
public interface ClobA Java interface mapping for the SQL CLOB type.An SQL
CLOBtype stores a large array of characters as the value in a column of a database.The
java.sql.Clobinterface provides methods for setting and retrieving data in theClob, for queryingClobdata length, for searching for data within theClob.
-
-
Method Summary
All Methods Instance Methods Abstract Methods 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 Detail
-
getAsciiStream
InputStream getAsciiStream() throws SQLException
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
Reader getCharacterStream() throws SQLException
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
String getSubString(long pos, int length) throws SQLException
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
long length() throws SQLExceptionRetrieves 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
long position(Clob searchstr, long start) throws SQLException
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
long position(String searchstr, long start) throws SQLException
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
OutputStream setAsciiStream(long pos) throws SQLException
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
Writer setCharacterStream(long pos) throws SQLException
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
int setString(long pos, String str) throws SQLExceptionWrites 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
int setString(long pos, String str, int offset, int len) throws SQLExceptionWriteslencharacters 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
void truncate(long len) throws SQLExceptionTruncates 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
void free() throws SQLException
Frees any resources held by this clob. Afterfreeis called, calling method other thanfreewill throwSQLException(callingfreerepeatedly will do nothing).- Throws:
SQLException
-
getCharacterStream
Reader getCharacterStream(long pos, long length) throws SQLException
Returns aReaderthat readslengthcharacters from this clob, starting at 1-based offset {code pos}.- Throws:
SQLException
-
-