- java.lang.Object
-
- javax.sql.rowset.serial.SerialClob
-
- All Implemented Interfaces:
- Serializable, Cloneable, Clob
public class SerialClob extends Object implements Clob, Serializable, Cloneable
A serialized mapping in the Java programming language of an SQLCLOB
value.The
SerialClob
class provides a constructor for creating an instance from aClob
object. Note that theClob
object should have brought the SQLCLOB
value's data over to the client before aSerialClob
object is constructed from it. The data of an SQLCLOB
value can be materialized on the client as a stream of Unicode characters.SerialClob
methods make it possible to get a substring from aSerialClob
object or to locate the start of a pattern of characters.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description SerialClob(char[] ch)
Constructs aSerialClob
object that is a serialized version of the givenchar
array.SerialClob(Clob clob)
Constructs aSerialClob
object that is a serialized version of the givenClob
object.
-
Method Summary
Methods Modifier and Type Method and Description void
free()
This method frees theClob
object and releases the resources the resources that it holds.InputStream
getAsciiStream()
Retrieves theCLOB
value designated by thisSerialClob
object as an ascii stream.Reader
getCharacterStream()
Returns thisSerialClob
object's data as a stream of Unicode characters.Reader
getCharacterStream(long pos, long length)
Returns aReader
object that contains a partialClob
value, starting with the character specified by pos, which is length characters in length.String
getSubString(long pos, int length)
Returns a copy of the substring contained in thisSerialClob
object, starting at the given position and continuing for the specified number or characters.long
length()
Retrieves the number of characters in thisSerialClob
object's array of characters.long
position(Clob searchStr, long start)
Returns the position in thisSerialClob
object where the givenClob
signature begins, starting the search at the specified position.long
position(String searchStr, long start)
Returns the position in thisSerialClob
object where the givenString
object begins, starting the search at the specified position.OutputStream
setAsciiStream(long pos)
Retrieves a stream to be used to write Ascii characters to theCLOB
value that thisSerialClob
object represents, starting at positionpos
.Writer
setCharacterStream(long pos)
Retrieves a stream to be used to write a stream of Unicode characters to theCLOB
value that thisSerialClob
object represents, at positionpos
.int
setString(long pos, String str)
Writes the given JavaString
to theCLOB
value that thisSerialClob
object represents, at the positionpos
.int
setString(long pos, String str, int offset, int length)
Writeslen
characters ofstr
, starting at characteroffset
, to theCLOB
value that thisClob
represents.void
truncate(long length)
Truncates theCLOB
value that thisSerialClob
object represents so that it has a length oflen
characters.
-
-
-
Constructor Detail
-
SerialClob
public SerialClob(char[] ch) throws SerialException, SQLException
Constructs aSerialClob
object that is a serialized version of the givenchar
array.The new
SerialClob
object is initialized with the data from thechar
array, thus allowing disconnectedRowSet
objects to establish a serializedClob
object without touching the data source.- Parameters:
ch
- the char array representing theClob
object to be serialized- Throws:
SerialException
- if an error occurs during serializationSQLException
- if a SQL error occurs
-
SerialClob
public SerialClob(Clob clob) throws SerialException, SQLException
Constructs aSerialClob
object that is a serialized version of the givenClob
object.The new
SerialClob
object is initialized with the data from theClob
object; therefore, theClob
object should have previously brought the SQLCLOB
value's data over to the client from the database. Otherwise, the newSerialClob
object object will contain no data.Note: The
Clob
object supplied to this constructor must return non-null for both theClob.getCharacterStream()
andClob.getAsciiStream
methods. ThisSerialClob
constructor cannot serialize aClob
object in this instance and will throw anSQLException
object.- Parameters:
clob
- theClob
object from which thisSerialClob
object is to be constructed; cannot be null- Throws:
SerialException
- if an error occurs during serializationSQLException
- if a SQL error occurs in capturing the CLOB; if theClob
object is a null; or if either of theClob.getCharacterStream()
andClob.getAsciiStream()
methods on theClob
returns a null- See Also:
Clob
-
-
Method Detail
-
length
public long length() throws SerialException
Retrieves the number of characters in thisSerialClob
object's array of characters.- Specified by:
length
in interfaceClob
- Returns:
- a
long
indicating the length in characters of thisSerialClob
object's array of character - Throws:
SerialException
- if an error occurs
-
getCharacterStream
public Reader getCharacterStream() throws SerialException
Returns thisSerialClob
object's data as a stream of Unicode characters. Unlike the related method,getAsciiStream
, a stream is produced regardless of whether theSerialClob
object was created with aClob
object or achar
array.- Specified by:
getCharacterStream
in interfaceClob
- Returns:
- a
java.io.Reader
object containing thisSerialClob
object's data - Throws:
SerialException
- if an error occurs- See Also:
Clob.setCharacterStream(long)
-
getAsciiStream
public InputStream getAsciiStream() throws SerialException, SQLException
Retrieves theCLOB
value designated by thisSerialClob
object as an ascii stream. This method forwards thegetAsciiStream
call to the underlyingClob
object in the event that thisSerialClob
object is instantiated with aClob
object. If thisSerialClob
object is instantiated with achar
array, aSerialException
object is thrown.- Specified by:
getAsciiStream
in interfaceClob
- Returns:
- a
java.io.InputStream
object containing thisSerialClob
object's data - Throws:
SerialException
- if thisSerialClob
object was not instantiated with aClob
objectSQLException
- if there is an error accessing theCLOB
value represented by theClob
object that was used to create thisSerialClob
object- See Also:
Clob.setAsciiStream(long)
-
getSubString
public String getSubString(long pos, int length) throws SerialException
Returns a copy of the substring contained in thisSerialClob
object, starting at the given position and continuing for the specified number or characters.- Specified by:
getSubString
in interfaceClob
- Parameters:
pos
- the position of the first character in the substring to be copied; the first character of theSerialClob
object is at position1
; must not be less than1
, and the sum of the starting position and the length of the substring must be less than the length of thisSerialClob
objectlength
- the number of characters in the substring to be returned; must not be greater than the length of thisSerialClob
object, and the sum of the starting position and the length of the substring must be less than the length of thisSerialClob
object- Returns:
- a
String
object containing a substring of thisSerialClob
object beginning at the given position and containing the specified number of consecutive characters - Throws:
SerialException
- if either of the arguments is out of bounds
-
position
public long position(String searchStr, long start) throws SerialException, SQLException
Returns the position in thisSerialClob
object where the givenString
object begins, starting the search at the specified position. This method returns-1
if the pattern is not found.- Specified by:
position
in interfaceClob
- Parameters:
searchStr
- theString
object for which to searchstart
- the position in thisSerialClob
object at which to start the search; the first position is1
; must not be less than1
nor greater than the length of thisSerialClob
object- Returns:
- the position at which the given
String
object begins, starting the search at the specified position;-1
if the givenString
object is not found or the starting position is out of bounds; position numbering for the return value starts at1
- Throws:
SerialException
- if an error occurs locating the String signatureSQLException
- if there is an error accessing the Blob value from the database.
-
position
public long position(Clob searchStr, long start) throws SerialException, SQLException
Returns the position in thisSerialClob
object where the givenClob
signature begins, starting the search at the specified position. This method returns-1
if the pattern is not found.- Specified by:
position
in interfaceClob
- Parameters:
searchStr
- theClob
object for which to searchstart
- the position in thisSerialClob
object at which to begin the search; the first position is1
; must not be less than1
nor greater than the length of thisSerialClob
object- Returns:
- the position at which the given
Clob
object begins in thisSerialClob
object, at or after the specified starting position - Throws:
SerialException
- if an error occurs locating the Clob signatureSQLException
- if there is an error accessing the Blob value from the database
-
setString
public int setString(long pos, String str) throws SerialException
Writes the given JavaString
to theCLOB
value that thisSerialClob
object represents, at the positionpos
.- Specified by:
setString
in interfaceClob
- Parameters:
pos
- the position at which to start writing to theCLOB
value that thisSerialClob
object represents; the first position is1
; must not be less than1
nor greater than the length of thisSerialClob
objectstr
- the string to be written to theCLOB
value that thisSerialClob
object represents- Returns:
- the number of characters written
- Throws:
SerialException
- if there is an error accessing theCLOB
value; if an invalid position is set; if an invalid offset value is set; if number of bytes to be written is greater than theSerialClob
length; or the combined values of the length and offset is greater than the Clob buffer
-
setString
public int setString(long pos, String str, int offset, int length) throws SerialException
Writeslen
characters ofstr
, starting at characteroffset
, to theCLOB
value that thisClob
represents.- Specified by:
setString
in interfaceClob
- Parameters:
pos
- the position at which to start writing to theCLOB
value that thisSerialClob
object represents; the first position is1
; must not be less than1
nor greater than the length of thisSerialClob
objectstr
- the string to be written to theCLOB
value that thisClob
object representsoffset
- the offset intostr
to start reading the characters to be writtenlength
- the number of characters to be written- Returns:
- the number of characters written
- Throws:
SerialException
- if there is an error accessing theCLOB
value; if an invalid position is set; if an invalid offset value is set; if number of bytes to be written is greater than theSerialClob
length; or the combined values of the length and offset is greater than the Clob buffer
-
setAsciiStream
public OutputStream setAsciiStream(long pos) throws SerialException, SQLException
Retrieves a stream to be used to write Ascii characters to theCLOB
value that thisSerialClob
object represents, starting at positionpos
. This method forwards thesetAsciiStream()
call to the underlyingClob
object in the event that thisSerialClob
object is instantiated with aClob
object. If thisSerialClob
object is instantiated with achar
array, aSerialException
object is thrown.- Specified by:
setAsciiStream
in interfaceClob
- Parameters:
pos
- the position at which to start writing to theCLOB
object- Returns:
- the stream to which ASCII encoded characters can be written
- Throws:
SerialException
- if SerialClob is not instantiated with a Clob object that supportssetAsciiStream
SQLException
- if there is an error accessing theCLOB
value- See Also:
getAsciiStream()
-
setCharacterStream
public Writer setCharacterStream(long pos) throws SerialException, SQLException
Retrieves a stream to be used to write a stream of Unicode characters to theCLOB
value that thisSerialClob
object represents, at positionpos
. This method forwards thesetCharacterStream()
call to the underlyingClob
object in the event that thisSerialClob
object is instantiated with aClob
object. If thisSerialClob
object is instantiated with achar
array, aSerialException
is thrown.- Specified by:
setCharacterStream
in interfaceClob
- Parameters:
pos
- the position at which to start writing to theCLOB
value- Returns:
- a stream to which Unicode encoded characters can be written
- Throws:
SerialException
- if the SerialClob is not instantiated with a Clob object that supportssetCharacterStream
SQLException
- if there is an error accessing theCLOB
value- See Also:
getCharacterStream()
-
truncate
public void truncate(long length) throws SerialException
Truncates theCLOB
value that thisSerialClob
object represents so that it has a length oflen
characters.Truncating a
SerialClob
object to length 0 has the effect of clearing its contents.- Specified by:
truncate
in interfaceClob
- Parameters:
length
- the length, in bytes, to which theCLOB
value should be truncated- Throws:
SQLException
- if there is an error accessing theCLOB
valueSerialException
-
getCharacterStream
public Reader getCharacterStream(long pos, long length) throws SQLException
Description copied from interface:Clob
Returns aReader
object that contains a partialClob
value, starting with the character specified by pos, which is length characters in length.- Specified by:
getCharacterStream
in interfaceClob
- Parameters:
pos
- the offset to the first character of the partial value to be retrieved. The first character in the Clob is at position 1.length
- the length in characters of the partial value to be retrieved.- Returns:
Reader
through which the partialClob
value can be read.- Throws:
SQLException
- if pos is less than 1 or if pos is greater than the number of characters in theClob
or if pos + length is greater than the number of characters in theClob
SQLFeatureNotSupportedException
- if the JDBC driver does not support this method
-
free
public void free() throws SQLException
Description copied from interface:Clob
This method frees theClob
object and releases the resources the resources that it holds. The object is invalid once thefree
method is called.After
free
has been called, any attempt to invoke a method other thanfree
will result in aSQLException
being thrown. Iffree
is called multiple times, the subsequent calls tofree
are treated as a no-op.- Specified by:
free
in interfaceClob
- Throws:
SQLException
- if an error occurs releasing the Clob's resourcesSQLFeatureNotSupportedException
- if the JDBC driver does not support this method
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
18/12/2024 19:51:53 Cette version de la page est en cache (à la date du 18/12/2024 19:51:53) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 01/09/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/sql/rowset/serial/SerialClob.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.