Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.mysql.jdbc
Class BlobFromLocator

    java.lang.Object
      com.mysql.jdbc.BlobFromLocator

All Implemented Interfaces:
  java.sql.Blob

    public class BlobFromLocator

extends java.lang.Object
implements java.sql.Blob

The representation (mapping) in the JavaTM programming language of an SQL BLOB value. An SQL BLOB is a built-in type that stores a Binary Large Object as a column value in a row of a database table. The driver implements Blob using an SQL locator(BLOB), which means that a Blob object contains a logical pointer to the SQL BLOB data rather than the data itself. A Blob object is valid for the duration of the transaction in which is was created. Methods in the interfaces ResultSet, CallableStatement, and PreparedStatement, such as getBlob and setBlob allow a programmer to access an SQL BLOB value. The Blob interface provides methods for getting the length of an SQL BLOB (Binary Large Object) value, for materializing a BLOB value on the client, and for determining the position of a pattern of bytes within a BLOB value. This class is new in the JDBC 2.0 API.

Nested Class Summary
`(package private) class` | `BlobFromLocator.LocatorInputStream`

Constructor Summary
`BlobFromLocator(ResultSetImpl creatorResultSetToSet, int blobColumnIndex, ExceptionInterceptor exceptionInterceptor)` Creates an updatable BLOB that can update in-place

Method Summary
`(package private) java.sql.PreparedStatement` | `createGetBytesStatement()`
`void` | `free()`
`java.io.InputStream` | `getBinaryStream()` Retrieves the BLOB designated by this Blob instance as a stream.
`java.io.InputStream` | `getBinaryStream(long pos, long length)`
`byte[]` | `getBytes(long pos, int length)` Returns as an array of bytes, part or all of the BLOB value that this Blob object designates.
`(package private) byte[]` | `getBytesInternal(java.sql.PreparedStatement pStmt, long pos, int length)`
`long` | `length()` Returns the number of bytes in the BLOB value designated by this Blob object.
`long` | `position(java.sql.Blob pattern, long start)` Finds the position of the given pattern in this BLOB.
`long` | `position(byte[] pattern, long start)`
`java.io.OutputStream` | `setBinaryStream(long indexToWriteAt)`
`int` | `setBytes(long writeAt, byte[] bytes)`
`int` | `setBytes(long writeAt, byte[] bytes, int offset, int length)`
`void` | `truncate(long length)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### BlobFromLocator

    BlobFromLocator(ResultSetImpl creatorResultSetToSet,
                    int blobColumnIndex,
                    ExceptionInterceptor exceptionInterceptor)
              throws java.sql.SQLException

  Creates an updatable BLOB that can update in-place

  Throws:
    `java.sql.SQLException`

Method Detail

### setBinaryStream

    public java.io.OutputStream setBinaryStream(long indexToWriteAt)
                                         throws java.sql.SQLException

  Specified by:
    `setBinaryStream` in interface `java.sql.Blob`
  Throws:
    `java.sql.SQLException`
  See Also:
    `Blob.setBinaryStream(long)`

### getBinaryStream

    public java.io.InputStream getBinaryStream()
                                        throws java.sql.SQLException

  Retrieves the BLOB designated by this Blob instance as a stream.

  Specified by:
    `getBinaryStream` in interface `java.sql.Blob`
  Returns:
    this BLOB represented as a binary stream of bytes.
  Throws:
    `java.sql.SQLException` - if a database error occurs

### setBytes

    public int setBytes(long writeAt,
                        byte[] bytes,
                        int offset,
                        int length)
                 throws java.sql.SQLException

  Specified by:
    `setBytes` in interface `java.sql.Blob`
  Throws:
    `java.sql.SQLException`
  See Also:
    `Blob.setBytes(long, byte[], int, int)`

### setBytes

    public int setBytes(long writeAt,
                        byte[] bytes)
                 throws java.sql.SQLException

  Specified by:
    `setBytes` in interface `java.sql.Blob`
  Throws:
    `java.sql.SQLException`
  See Also:
    `Blob.setBytes(long, byte[])`

### getBytes

    public byte[] getBytes(long pos,
                           int length)
                    throws java.sql.SQLException

  Returns as an array of bytes, part or all of the BLOB value that this Blob object designates.

  Specified by:
    `getBytes` in interface `java.sql.Blob`
  Parameters:
    `pos` - where to start the part of the BLOB
    `length` - the length of the part of the BLOB you want returned.
  Returns:
    the bytes stored in the blob starting at position `pos` and having a length of `length`.
  Throws:
    `java.sql.SQLException` - if a database error occurs

### length

    public long length()
                throws java.sql.SQLException

  Returns the number of bytes in the BLOB value designated by this Blob object.

  Specified by:
    `length` in interface `java.sql.Blob`
  Returns:
    the length of this blob
  Throws:
    `java.sql.SQLException` - if a database error occurs

### position

    public long position(java.sql.Blob pattern,
                         long start)
                  throws java.sql.SQLException

  Finds the position of the given pattern in this BLOB.

  Specified by:
    `position` in interface `java.sql.Blob`
  Parameters:
    `pattern` - the pattern to find
    `start` - where to start finding the pattern
  Returns:
    the position where the pattern is found in the BLOB, -1 if not found
  Throws:
    `java.sql.SQLException` - if a database error occurs

### position

    public long position(byte[] pattern,
                         long start)
                  throws java.sql.SQLException

  Specified by:
    `position` in interface `java.sql.Blob`
  Throws:
    `java.sql.SQLException`
  See Also:
    `Blob.position(byte[], long)`

### truncate

    public void truncate(long length)
                  throws java.sql.SQLException

  Specified by:
    `truncate` in interface `java.sql.Blob`
  Throws:
    `java.sql.SQLException`
  See Also:
    `Blob.truncate(long)`

### createGetBytesStatement

    java.sql.PreparedStatement createGetBytesStatement()
                                                 throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getBytesInternal

    byte[] getBytesInternal(java.sql.PreparedStatement pStmt,
                            long pos,
                            int length)
                      throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### free

    public void free()
              throws java.sql.SQLException

  Specified by:
    `free` in interface `java.sql.Blob`
  Throws:
    `java.sql.SQLException`

### getBinaryStream

    public java.io.InputStream getBinaryStream(long pos,
                                               long length)
                                        throws java.sql.SQLException

  Specified by:
    `getBinaryStream` in interface `java.sql.Blob`
  Throws:
    `java.sql.SQLException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD