java.lang.Object
com.microsoft.sqlserver.jdbc.SQLServerNClob
- All Implemented Interfaces:
Serializable
,Clob
,NClob
Represents a National Character Set LOB object and implements java.sql.NClob.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
free()
Frees this Clob/NClob object and releases the resources that it holds.Returns the CLOB as an ASCII stream.Returns the CLOB value designated by this Clob object as a java.io.Reader object (or as a stream of characters).getCharacterStream
(long pos, long length) Returns the Clob data as a java.io.Reader object or as a stream of characters with the specified position and length.getSubString
(long pos, int length) Returns a copy of the specified substring in the CLOB value designated by this Clob object.long
length()
Returns the number of characters in the CLOB value designated by this Clob object.long
Returns the character position at which the specified substring searchstr appears in the SQL CLOB value represented by this Clob object.long
Returns the character position at which the specified Clob object searchstr appears in this Clob object.setAsciiStream
(long pos) Returns a stream to be used to write Ascii characters to the CLOB value that this Clob object represents, starting at position pos.setCharacterStream
(long pos) Returns a stream to be used to write a stream of Unicode characters to the CLOB value that this Clob object represents, at position pos.protected void
Sets the default charsetint
Writes the given Java String to the CLOB value that this Clob object designates at the position pos.int
Writes len characters of str, starting at character offset, to the CLOB value that this Clob represents.final String
toString()
void
truncate
(long len) Truncates the CLOB value that this Clob designates to have a length of len characters.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.sql.Clob
free, getCharacterStream, getCharacterStream, getSubString, length, position, position, setAsciiStream, setCharacterStream, setString, setString, truncate
-
Method Details
-
getAsciiStream
Returns the CLOB as an ASCII stream.- Specified by:
getAsciiStream
in interfaceClob
- Returns:
- the data as an input stream
- Throws:
SQLException
- when an error occurs
-
toString
-
free
Frees this Clob/NClob object and releases the resources that it holds. After free() has been called, any attempt to invoke a method other than free() will result in a SQLException being thrown. If free() is called multiple times, the subsequent calls to free are treated as a no-op.- Throws:
SQLException
- when an error occurs
-
getCharacterStream
Returns the CLOB value designated by this Clob object as a java.io.Reader object (or as a stream of characters).- Returns:
- a java.io.Reader object containing the CLOB data
- Throws:
SQLException
- if there is an error accessing the CLOB value
-
getCharacterStream
Returns the Clob data as a java.io.Reader object or as a stream of characters with the specified position and length.- Parameters:
pos
- A long that indicates the offset to the first character of the partial value to be retrieved.length
- A long that indicates the length in characters of the partial value to be retrieved.- Returns:
- A Reader object that contains the Clob data.
- Throws:
SQLException
- when an error occurs.
-
getSubString
Returns a copy of the specified substring in the CLOB value designated by this Clob object. The substring begins at position pos and has up to length consecutive characters.- Parameters:
pos
- - the first character of the substring to be extracted. The first character is at position 1.length
- - the number of consecutive characters to be copied; the value for length must be 0 or greater- Returns:
- a String that is the specified substring in the CLOB value designated by this Clob object
- Throws:
SQLException
- - if there is an error accessing the CLOB value; if pos is less than 1 or length is less than 0
-
length
Returns the number of characters in the CLOB value designated by this Clob object.- Returns:
- length of the CLOB in characters
- Throws:
SQLException
- when an error occurs
-
position
Returns the character position at which the specified Clob object searchstr appears in this Clob object. The search begins at position start.- Parameters:
searchstr
- - the Clob for which to searchstart
- - the position at which to begin searching; the first position is 1- Returns:
- the position at which the Clob object appears or -1 if it is not present; the first position is 1
- Throws:
SQLException
- - if there is an error accessing the CLOB value or if start is less than 1
-
position
Returns the character position at which the specified substring searchstr appears in the SQL CLOB value represented by this Clob object. The search begins at position start.- Parameters:
searchstr
- - the substring for which to searchstart
- - the position at which to begin searching; the first position is 1- Returns:
- the position at which the substring appears or -1 if it is not present; the first position is 1
- Throws:
SQLException
- - if there is an error accessing the CLOB value or if start is less than 1
-
truncate
Truncates the CLOB value that this Clob designates to have a length of len characters.- Parameters:
len
- the length, in characters, to which the CLOB value should be truncated- Throws:
SQLException
- when an error occurs
-
setAsciiStream
Returns a stream to be used to write Ascii characters to the CLOB value that this Clob object represents, starting at position pos.- Parameters:
pos
- the position at which to start writing to this CLOB object- Returns:
- the stream to which ASCII encoded characters can be written
- Throws:
SQLException
- when an error occurs
-
setCharacterStream
Returns a stream to be used to write a stream of Unicode characters to the CLOB value that this Clob object represents, at position pos.- Parameters:
pos
- the position at which to start writing to the CLOB value- Returns:
- a stream to which Unicode encoded characters can be written
- Throws:
SQLException
- when an error occurs
-
setString
Writes the given Java String to the CLOB value that this Clob object designates at the position pos.- Parameters:
pos
- the position at which to start writing to the CLOBs
- the string to be written to the CLOB value that this Clob designates- Returns:
- the number of characters written
- Throws:
SQLException
- when an error occurs
-
setString
Writes len characters of str, starting at character offset, to the CLOB value that this Clob represents. The string will overwrite the existing characters in the Clob object starting at the position pos. If the end of the Clob value is reached while writing the given string, then the length of the Clob value will be increased to accommodate the extra characters. SQL Server behavior: If the value specified for pos is greater than then length+1 of the CLOB value then a SQLException is thrown.- Parameters:
pos
- - the position at which to start writing to this CLOB object; The first position is 1str
- - the string to be written to the CLOB value that this Clob object representsoffset
- - the offset (0-based) into str to start reading the characters to be writtenlen
- - the number of characters to be written- Returns:
- the number of characters written
- Throws:
SQLException
- - if there is an error accessing the CLOB value or if pos is less than 1
-
setDefaultCharset
Sets the default charset- Parameters:
c
- charset
-