Class com.imaginary.sql.msql.MsqlBlob
java.lang.Object
|
+--com.imaginary.sql.msql.MsqlBlob
- public class MsqlBlob
- extends java.lang.Object
- implements java.sql.Blob
Implements the JDBC 2.0 Blob
interface. Under mSQL,
there are no binary data types. There is therefore no optimization in
using Blob
objects. This implementation exists simply to make
it easier to write platform independent database code.
Last modified $Date: 1999/03/03 03:27:06 $
- Version:
- $Revision: 2.1 $
- Author:
- George Reese (borg@imaginary.com)
Constructor Summary
|
MsqlBlob(byte[] b)
Constructs a new MsqlBlob from the specified byte array. |
MsqlBlob(java.io.InputStream is)
Constructs a new MsqlBlob from a binary stream. |
Method Summary
|
java.io.InputStream
|
getBinaryStream()
|
byte[]
|
getBytes(long pos,
int len)
Provides a byte array of data from this Blob
starting at the specified start position within this Blob
and having the specified length. |
long
|
length()
|
long
|
position(java.sql.Blob pattern,
long start)
Provides the position of the first occurrence of the specified pattern
after the specified start position. |
long
|
position(byte[] pattern,
long start)
Provides the position of the first occurrence of the specified pattern
after the specified start position. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait |
MsqlBlob
public MsqlBlob(byte[] b)
- Constructs a new
MsqlBlob
from the specified byte array.
- Parameters:
b
- the array of bytes this Blob
represents
MsqlBlob
public MsqlBlob(java.io.InputStream is)
throws java.sql.SQLException
- Constructs a new
MsqlBlob
from a binary stream.
- Parameters:
is
- the stream from which this Blob
will be
created- Throws:
- java.sql.SQLException - a database error occurred
getBinaryStream
public java.io.InputStream getBinaryStream()
throws java.sql.SQLException
- Description copied from interface:
- Specified by:
- getBinaryStream() in interface java.sql.Blob
- Returns:
- the
Blob
as an InputStream
- Throws:
- java.sql.SQLException - could not construct the input stream
getBytes
public byte[] getBytes(long pos,
int len)
throws java.sql.SQLException
- Provides a byte array of data from this
Blob
starting at the specified start position within this Blob
and having the specified length. Note that the first argument is
a long
as required by the JDBC 2.0 specification.
Because mSQL has no binary types and mSQL does some fudging via
base 64 encoding to support binary types, you will never end up with
a Blob
in mSQL whose start position is greater than
Integer.MAX_VALUE
.
- Specified by:
- getBytes(long, int) in interface java.sql.Blob
- Parameters:
pos
- the start position
len
- the length of the desired return array- Returns:
- an array of the bytes of this
Blob
from the
specified start position up to the specified length - Throws:
- java.sql.SQLException - the position argument was greater
than the size of the
Blob
.
length
public long length()
throws java.sql.SQLException
- Description copied from interface:
- Specified by:
- length() in interface java.sql.Blob
- Returns:
- the number of bytes in this
Blob
- Throws:
- java.sql.SQLException - this is never thrown in mSQL-JDBC
position
public long position(java.sql.Blob pattern,
long start)
throws java.sql.SQLException
- Provides the position of the first occurrence of the specified pattern
after the specified start position.
- Specified by:
- position(java.sql.Blob, long) in interface java.sql.Blob
- Parameters:
pattern
- a Blob
representing the desired pattern
start
- the index from which to start the search measured
from 1- Returns:
- the index of the first occurrence of the specified pattern
or -1 if the pattern does not occur
- Throws:
- java.sql.SQLException - this is never thrown in mSQL-JDBC
position
public long position(byte[] pattern,
long start)
throws java.sql.SQLException
- Provides the position of the first occurrence of the specified pattern
after the specified start position.
- Specified by:
- position(byte[], long) in interface java.sql.Blob
- Parameters:
pattern
- a byte array representing the desired pattern
start
- the index from which to start the search measured
from 1- Returns:
- the index of the first occurrence of the specified pattern
or -1 if the pattern does not occur
- Throws:
- java.sql.SQLException - this is never thrown in mSQL-JDBC