Class BlobFromLocator
java.lang.Object
com.mysql.jdbc.BlobFromLocator
- All Implemented Interfaces:
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
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionBlobFromLocator(ResultSetImpl creatorResultSetToSet, int blobColumnIndex, ExceptionInterceptor exceptionInterceptor) Creates an updatable BLOB that can update in-place -
Method Summary
Modifier and TypeMethodDescription(package private) PreparedStatementvoidfree()Retrieves the BLOB designated by this Blob instance as a stream.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(PreparedStatement pStmt, long pos, int length) longlength()Returns the number of bytes in the BLOB value designated by this Blob object.longposition(byte[] pattern, long start) longFinds the position of the given pattern in this BLOB.setBinaryStream(long indexToWriteAt) intsetBytes(long writeAt, byte[] bytes) intsetBytes(long writeAt, byte[] bytes, int offset, int length) voidtruncate(long length)
-
Constructor Details
-
BlobFromLocator
BlobFromLocator(ResultSetImpl creatorResultSetToSet, int blobColumnIndex, ExceptionInterceptor exceptionInterceptor) throws SQLException Creates an updatable BLOB that can update in-place- Throws:
SQLException
-
-
Method Details
-
setBinaryStream
- Specified by:
setBinaryStreamin interfaceBlob- Throws:
SQLException- See Also:
-
getBinaryStream
Retrieves the BLOB designated by this Blob instance as a stream.- Specified by:
getBinaryStreamin interfaceBlob- Returns:
- this BLOB represented as a binary stream of bytes.
- Throws:
SQLException- if a database error occurs
-
setBytes
- Specified by:
setBytesin interfaceBlob- Throws:
SQLException- See Also:
-
setBytes
- Specified by:
setBytesin interfaceBlob- Throws:
SQLException- See Also:
-
getBytes
Returns as an array of bytes, part or all of the BLOB value that this Blob object designates.- Specified by:
getBytesin interfaceBlob- Parameters:
pos- where to start the part of the BLOBlength- the length of the part of the BLOB you want returned.- Returns:
- the bytes stored in the blob starting at position
posand having a length oflength. - Throws:
SQLException- if a database error occurs
-
length
Returns the number of bytes in the BLOB value designated by this Blob object.- Specified by:
lengthin interfaceBlob- Returns:
- the length of this blob
- Throws:
SQLException- if a database error occurs
-
position
Finds the position of the given pattern in this BLOB.- Specified by:
positionin interfaceBlob- Parameters:
pattern- the pattern to findstart- where to start finding the pattern- Returns:
- the position where the pattern is found in the BLOB, -1 if not found
- Throws:
SQLException- if a database error occurs
-
position
- Specified by:
positionin interfaceBlob- Throws:
SQLException- See Also:
-
truncate
- Specified by:
truncatein interfaceBlob- Throws:
SQLException- See Also:
-
createGetBytesStatement
- Throws:
SQLException
-
getBytesInternal
- Throws:
SQLException
-
free
- Specified by:
freein interfaceBlob- Throws:
SQLException
-
getBinaryStream
- Specified by:
getBinaryStreamin interfaceBlob- Throws:
SQLException
-