javax.sql.rowset.serial
Class SerialBlob

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.sql.rowset.serial.SerialBlob
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable , Blob sample code for java.sql.Blob definition code for java.sql.Blob

public class SerialBlob
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements Blob sample code for java.sql.Blob definition code for java.sql.Blob , Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable

A serialized mapping in the Java programming language of an SQL BLOB value.

The SerialBlob class provides a constructor for creating an instance from a Blob object. Note that the Blob object should have brought the SQL BLOB value's data over to the client before a SerialBlob object is constructed from it. The data of an SQL BLOB value can be materialized on the client as an array of bytes (using the method Blob.getBytes) or as a stream of uninterpreted bytes (using the method Blob.getBinaryStream).

SerialBlob methods make it possible to make a copy of a SerialBlob object as an array of bytes or as a stream. They also make it possible to locate a given pattern of bytes or a Blob object within a SerialBlob object and to update or truncate a Blob object.

See Also:
Serialized Form

Constructor Summary
SerialBlob sample code for javax.sql.rowset.serial.SerialBlob.SerialBlob(java.sql.Blob) definition code for javax.sql.rowset.serial.SerialBlob.SerialBlob(java.sql.Blob) (Blob sample code for java.sql.Blob definition code for java.sql.Blob  blob)
          Constructs a SerialBlob object that is a serialized version of the given Blob object.
SerialBlob sample code for javax.sql.rowset.serial.SerialBlob.SerialBlob(byte[]) definition code for javax.sql.rowset.serial.SerialBlob.SerialBlob(byte[]) (byte[] b)
          Constructs a SerialBlob object that is a serialized version of the given byte array.
 
Method Summary
 InputStream sample code for java.io.InputStream definition code for java.io.InputStream getBinaryStream sample code for javax.sql.rowset.serial.SerialBlob.getBinaryStream() definition code for javax.sql.rowset.serial.SerialBlob.getBinaryStream() ()
          Returns this SerialBlob object as an input stream.
 byte[] getBytes sample code for javax.sql.rowset.serial.SerialBlob.getBytes(long, int) definition code for javax.sql.rowset.serial.SerialBlob.getBytes(long, int) (long pos, int length)
          Copies the specified number of bytes, starting at the given position, from this SerialBlob object to another array of bytes.
 long length sample code for javax.sql.rowset.serial.SerialBlob.length() definition code for javax.sql.rowset.serial.SerialBlob.length() ()
          Retrieves the number of bytes in this SerialBlob object's array of bytes.
 long position sample code for javax.sql.rowset.serial.SerialBlob.position(java.sql.Blob, long) definition code for javax.sql.rowset.serial.SerialBlob.position(java.sql.Blob, long) (Blob sample code for java.sql.Blob definition code for java.sql.Blob  pattern, long start)
          Returns the position in this SerialBlob object where the given Blob object begins, starting the search at the specified position.
 long position sample code for javax.sql.rowset.serial.SerialBlob.position(byte[], long) definition code for javax.sql.rowset.serial.SerialBlob.position(byte[], long) (byte[] pattern, long start)
          Returns the position in this SerialBlob object where the given pattern of bytes begins, starting the search at the specified position.
 OutputStream sample code for java.io.OutputStream definition code for java.io.OutputStream setBinaryStream sample code for javax.sql.rowset.serial.SerialBlob.setBinaryStream(long) definition code for javax.sql.rowset.serial.SerialBlob.setBinaryStream(long) (long pos)
          Retrieves a stream that can be used to write to the BLOB value that this Blob object represents.
 int setBytes sample code for javax.sql.rowset.serial.SerialBlob.setBytes(long, byte[]) definition code for javax.sql.rowset.serial.SerialBlob.setBytes(long, byte[]) (long pos, byte[] bytes)
          Writes the given array of bytes to the BLOB value that this Blob object represents, starting at position pos, and returns the number of bytes written.
 int setBytes sample code for javax.sql.rowset.serial.SerialBlob.setBytes(long, byte[], int, int) definition code for javax.sql.rowset.serial.SerialBlob.setBytes(long, byte[], int, int) (long pos, byte[] bytes, int offset, int length)
          Writes all or part of the given byte array to the BLOB value that this Blob object represents and returns the number of bytes written.
 void truncate sample code for javax.sql.rowset.serial.SerialBlob.truncate(long) definition code for javax.sql.rowset.serial.SerialBlob.truncate(long) (long length)
          Truncates the BLOB value that this Blob object represents to be len bytes in length.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

SerialBlob sample code for javax.sql.rowset.serial.SerialBlob(byte[]) definition code for javax.sql.rowset.serial.SerialBlob(byte[])

public SerialBlob(byte[] b)
           throws SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException ,
                  SQLException sample code for java.sql.SQLException definition code for java.sql.SQLException 
Constructs a SerialBlob object that is a serialized version of the given byte array.

The new SerialBlob object is initialized with the data from the byte array, thus allowing disconnected RowSet objects to establish serialized Blob objects without touching the data source.

Parameters:
b - the byte array containing the data for the Blob object to be serialized
Throws:
SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException - if an error occurs during serialization
SQLException sample code for java.sql.SQLException definition code for java.sql.SQLException - if a SQL errors occurs

SerialBlob sample code for javax.sql.rowset.serial.SerialBlob(java.sql.Blob) definition code for javax.sql.rowset.serial.SerialBlob(java.sql.Blob)

public SerialBlob(Blob sample code for java.sql.Blob definition code for java.sql.Blob  blob)
           throws SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException ,
                  SQLException sample code for java.sql.SQLException definition code for java.sql.SQLException 
Constructs a SerialBlob object that is a serialized version of the given Blob object.

The new SerialBlob object is initialized with the data from the Blob object; therefore, the Blob object should have previously brought the SQL BLOB value's data over to the client from the database. Otherwise, the new SerialBlob object will contain no data.

Parameters:
blob - the Blob object from which this SerialBlob object is to be constructed; cannot be null.
Throws:
SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException - if an error occurs during serialization
SQLException sample code for java.sql.SQLException definition code for java.sql.SQLException - if the Blob passed to this to this constructor is a null.
See Also:
Blob sample code for java.sql.Blob definition code for java.sql.Blob
Method Detail

getBytes sample code for javax.sql.rowset.serial.SerialBlob.getBytes(long, int) definition code for javax.sql.rowset.serial.SerialBlob.getBytes(long, int)

public byte[] getBytes(long pos,
                       int length)
                throws SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException 
Copies the specified number of bytes, starting at the given position, from this SerialBlob object to another array of bytes.

Note that if the given number of bytes to be copied is larger than the length of this SerialBlob object's array of bytes, the given number will be shortened to the array's length.

Specified by:
getBytes sample code for java.sql.Blob.getBytes(long, int) definition code for java.sql.Blob.getBytes(long, int) in interface Blob sample code for java.sql.Blob definition code for java.sql.Blob
Parameters:
pos - the ordinal position of the first byte in this SerialBlob object to be copied; numbering starts at 1; must not be less than 1 and must be less than or equal to the length of this SerialBlob object
length - the number of bytes to be copied
Returns:
an array of bytes that is a copy of a region of this SerialBlob object, starting at the given position and containing the given number of consecutive bytes
Throws:
SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException - if the given starting position is out of bounds
See Also:
Blob.setBytes(long, byte[]) sample code for java.sql.Blob.setBytes(long, byte[]) definition code for java.sql.Blob.setBytes(long, byte[])

length sample code for javax.sql.rowset.serial.SerialBlob.length() definition code for javax.sql.rowset.serial.SerialBlob.length()

public long length()
            throws SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException 
Retrieves the number of bytes in this SerialBlob object's array of bytes.

Specified by:
length sample code for java.sql.Blob.length() definition code for java.sql.Blob.length() in interface Blob sample code for java.sql.Blob definition code for java.sql.Blob
Returns:
a long indicating the length in bytes of this SerialBlob object's array of bytes
Throws:
SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException - if an error occurs

getBinaryStream sample code for javax.sql.rowset.serial.SerialBlob.getBinaryStream() definition code for javax.sql.rowset.serial.SerialBlob.getBinaryStream()

public InputStream sample code for java.io.InputStream definition code for java.io.InputStream  getBinaryStream()
                            throws SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException 
Returns this SerialBlob object as an input stream. Unlike the related method, setBinaryStream, a stream is produced regardless of whether the SerialBlob was created with a Blob object or a byte array.

Specified by:
getBinaryStream sample code for java.sql.Blob.getBinaryStream() definition code for java.sql.Blob.getBinaryStream() in interface Blob sample code for java.sql.Blob definition code for java.sql.Blob
Returns:
a java.io.InputStream object that contains this SerialBlob object's array of bytes
Throws:
SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException - if an error occurs
See Also:
setBinaryStream(long) sample code for javax.sql.rowset.serial.SerialBlob.setBinaryStream(long) definition code for javax.sql.rowset.serial.SerialBlob.setBinaryStream(long)

position sample code for javax.sql.rowset.serial.SerialBlob.position(byte[], long) definition code for javax.sql.rowset.serial.SerialBlob.position(byte[], long)

public long position(byte[] pattern,
                     long start)
              throws SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException ,
                     SQLException sample code for java.sql.SQLException definition code for java.sql.SQLException 
Returns the position in this SerialBlob object where the given pattern of bytes begins, starting the search at the specified position.

Specified by:
position sample code for java.sql.Blob.position(byte[], long) definition code for java.sql.Blob.position(byte[], long) in interface Blob sample code for java.sql.Blob definition code for java.sql.Blob
Parameters:
pattern - the pattern of bytes for which to search
start - the position of the byte in this SerialBlob object from which to begin the search; the first position is 1; must not be less than 1 nor greater than the length of this SerialBlob object
Returns:
the position in this SerialBlob object where the given pattern begins, starting at the specified position; -1 if the pattern is not found or the given starting position is out of bounds; position numbering for the return value starts at 1
Throws:
SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException - if an error occurs when serializing the blob
SQLException sample code for java.sql.SQLException definition code for java.sql.SQLException - if there is an error accessing the BLOB value from the database

position sample code for javax.sql.rowset.serial.SerialBlob.position(java.sql.Blob, long) definition code for javax.sql.rowset.serial.SerialBlob.position(java.sql.Blob, long)

public long position(Blob sample code for java.sql.Blob definition code for java.sql.Blob  pattern,
                     long start)
              throws SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException ,
                     SQLException sample code for java.sql.SQLException definition code for java.sql.SQLException 
Returns the position in this SerialBlob object where the given Blob object begins, starting the search at the specified position.

Specified by:
position sample code for java.sql.Blob.position(java.sql.Blob, long) definition code for java.sql.Blob.position(java.sql.Blob, long) in interface Blob sample code for java.sql.Blob definition code for java.sql.Blob
Parameters:
pattern - the Blob object for which to search;
start - the position of the byte in this SerialBlob object from which to begin the search; the first position is 1; must not be less than 1 nor greater than the length of this SerialBlob object
Returns:
the position in this SerialBlob object where the given Blob object begins, starting at the specified position; -1 if the pattern is not found or the given starting position is out of bounds; position numbering for the return value starts at 1
Throws:
SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException - if an error occurs when serializing the blob
SQLException sample code for java.sql.SQLException definition code for java.sql.SQLException - if there is an error accessing the BLOB value from the database

setBytes sample code for javax.sql.rowset.serial.SerialBlob.setBytes(long, byte[]) definition code for javax.sql.rowset.serial.SerialBlob.setBytes(long, byte[])

public int setBytes(long pos,
                    byte[] bytes)
             throws SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException ,
                    SQLException sample code for java.sql.SQLException definition code for java.sql.SQLException 
Writes the given array of bytes to the BLOB value that this Blob object represents, starting at position pos, and returns the number of bytes written.

Specified by:
setBytes sample code for java.sql.Blob.setBytes(long, byte[]) definition code for java.sql.Blob.setBytes(long, byte[]) in interface Blob sample code for java.sql.Blob definition code for java.sql.Blob
Parameters:
pos - the position in the SQL BLOB value at which to start writing. The first position is 1; must not be less than 1 nor greater than the length of this SerialBlob object.
bytes - the array of bytes to be written to the BLOB value that this Blob object represents
Returns:
the number of bytes written
Throws:
SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException - if there is an error accessing the BLOB value; or if an invalid position is set; if an invalid offset value is set
SQLException sample code for java.sql.SQLException definition code for java.sql.SQLException - if there is an error accessing the BLOB value from the database
See Also:
getBytes(long, int) sample code for javax.sql.rowset.serial.SerialBlob.getBytes(long, int) definition code for javax.sql.rowset.serial.SerialBlob.getBytes(long, int)

setBytes sample code for javax.sql.rowset.serial.SerialBlob.setBytes(long, byte[], int, int) definition code for javax.sql.rowset.serial.SerialBlob.setBytes(long, byte[], int, int)

public int setBytes(long pos,
                    byte[] bytes,
                    int offset,
                    int length)
             throws SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException ,
                    SQLException sample code for java.sql.SQLException definition code for java.sql.SQLException 
Writes all or part of the given byte array to the BLOB value that this Blob object represents and returns the number of bytes written. Writing starts at position pos in the BLOB value; len bytes from the given byte array are written.

Specified by:
setBytes sample code for java.sql.Blob.setBytes(long, byte[], int, int) definition code for java.sql.Blob.setBytes(long, byte[], int, int) in interface Blob sample code for java.sql.Blob definition code for java.sql.Blob
Parameters:
pos - the position in the BLOB object at which to start writing. The first position is 1; must not be less than 1 nor greater than the length of this SerialBlob object.
bytes - the array of bytes to be written to the BLOB value
offset - the offset in the byte array at which to start reading the bytes. The first offset position is 0; must not be less than 0 nor greater than the length of the byte array
length - the number of bytes to be written to the BLOB value from the array of bytes bytes.
Returns:
the number of bytes written
Throws:
SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException - if there is an error accessing the BLOB value; if an invalid position is set; if an invalid offset value is set; if number of bytes to be written is greater than the SerialBlob length; or the combined values of the length and offset is greater than the Blob buffer
SQLException sample code for java.sql.SQLException definition code for java.sql.SQLException - if there is an error accessing the BLOB value from the database.
See Also:
getBytes(long, int) sample code for javax.sql.rowset.serial.SerialBlob.getBytes(long, int) definition code for javax.sql.rowset.serial.SerialBlob.getBytes(long, int)

setBinaryStream sample code for javax.sql.rowset.serial.SerialBlob.setBinaryStream(long) definition code for javax.sql.rowset.serial.SerialBlob.setBinaryStream(long)

public OutputStream sample code for java.io.OutputStream definition code for java.io.OutputStream  setBinaryStream(long pos)
                             throws SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException ,
                                    SQLException sample code for java.sql.SQLException definition code for java.sql.SQLException 
Retrieves a stream that can be used to write to the BLOB value that this Blob object represents. The stream begins at position pos. This method forwards the setBinaryStream() call to the underlying Blob in the event that this SerialBlob object is instantiated with a Blob. If this SerialBlob is instantiated with a byte array, a SerialException is thrown.

Specified by:
setBinaryStream sample code for java.sql.Blob.setBinaryStream(long) definition code for java.sql.Blob.setBinaryStream(long) in interface Blob sample code for java.sql.Blob definition code for java.sql.Blob
Parameters:
pos - the position in the BLOB value at which to start writing
Returns:
a java.io.OutputStream object to which data can be written
Throws:
SQLException sample code for java.sql.SQLException definition code for java.sql.SQLException - if there is an error accessing the BLOB value
SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException - if the SerialBlob in not instantiated with a Blob object that supports setBinaryStream()
See Also:
getBinaryStream() sample code for javax.sql.rowset.serial.SerialBlob.getBinaryStream() definition code for javax.sql.rowset.serial.SerialBlob.getBinaryStream()

truncate sample code for javax.sql.rowset.serial.SerialBlob.truncate(long) definition code for javax.sql.rowset.serial.SerialBlob.truncate(long)

public void truncate(long length)
              throws SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException 
Truncates the BLOB value that this Blob object represents to be len bytes in length.

Specified by:
truncate sample code for java.sql.Blob.truncate(long) definition code for java.sql.Blob.truncate(long) in interface Blob sample code for java.sql.Blob definition code for java.sql.Blob
Parameters:
length - the length, in bytes, to which the BLOB value that this Blob object represents should be truncated
Throws:
SerialException sample code for javax.sql.rowset.serial.SerialException definition code for javax.sql.rowset.serial.SerialException - if there is an error accessing the Blob value; or the length to truncate is greater that the SerialBlob length