Top Description Fields Constructors Methods
org.apache.derby.iapi.types

public Class SQLBlob

extends SQLBinary
Class Inheritance
Imports
org.apache.derby.shared.common.reference.SQLState, .Limits, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.io.CloneableStream, .StoredFormatIds, org.apache.derby.shared.common.sanity.SanityManager, java.sql.Blob, .ResultSet, .SQLException, .PreparedStatement

SQLBlob satisfies the DataValueDescriptor, interfaces (i.e., OrderableDataType). It uses the SQLLongVarbit implementation, which implements a String holder, e.g. for storing a column value; it can be specified when constructed to not allow nulls. Nullability cannot be changed after construction.

Because LOB types are not orderable, we'll override those methods...

Field Summary

Inherited from org.apache.derby.iapi.types.SQLBinary:
_blobValuedataValuePADstreamstreamValueLength

Constructor Summary

AccessConstructor and Description
public
public
SQLBlob(byte[] val)

public

Method Summary

Modifier and TypeMethod and Description
public DataValueDescriptor

Returns:

A clone of this BLOB value.
cloneValue
(boolean
any streams representing the data value will be materialized if true, the data value will be kept as a stream if possible if false
forceMaterialization
)

Overrides org.apache.derby.iapi.types.SQLBinary.cloneValue.

Implements org.apache.derby.iapi.types.DataValueDescriptor.cloneValue.

Returns a clone of this BLOB value.

pack-priv int
getMaxMemoryUsage()

Implements abstract org.apache.derby.iapi.types.SQLBinary.getMaxMemoryUsage.

Return max memory usage for a SQL Blob

public DataValueDescriptor
getNewNull()

Implements org.apache.derby.iapi.types.DataValueDescriptor.getNewNull.

Get a new null value of the same type as this data value.

public Object
public int
public String
getTypeName()

Implements org.apache.derby.iapi.types.DataValueDescriptor.getTypeName.

Get the SQL name of the datatype

public boolean

Returns:

true if the value is represented by a stream, false otherwise.
hasStream
()

Overrides org.apache.derby.iapi.types.DataType.hasStream.

Implements org.apache.derby.iapi.types.DataValueDescriptor.hasStream.

Tells if this BLOB value is, or will be, represented by a stream.

private final boolean

Returns:

true if the length of the blob is not known, false otherwise
isLengthLess
()

Tell if this blob is length less.

public void
normalize(DataTypeDescriptor
The type to normalize the source column to
desiredType
,
DataValueDescriptor
The value to normalize
source
)

Overrides org.apache.derby.iapi.types.DataType.normalize.

Implements org.apache.derby.iapi.types.DataValueDescriptor.normalize.

Normalization method - this method may be called when putting a value into a SQLBit, for example, when inserting into a SQLBit column.

public void
setInto(PreparedStatement ps, int position)

Overrides org.apache.derby.iapi.types.SQLBinary.setInto.

Implements org.apache.derby.iapi.types.DataValueDescriptor.setInto.

Adding this method to ensure that super class' setInto method doesn't get called that leads to the violation of JDBC spec( untyped nulls ) when batching is turned on.

pack-priv final void
setObject(Object theValue)

Overrides org.apache.derby.iapi.types.DataType.setObject.

Set the value from an non-null object.

public void
setValueFromResultSet(ResultSet
The specified ResultSet.
resultSet
,
int
The 1-based column # into the resultSet.
colNumber
,
boolean
Whether or not the column is nullable (No need to call wasNull() if not)
isNullable
)

Implements org.apache.derby.iapi.types.DataValueDescriptor.setValueFromResultSet.

Set the value based on the value for the specified DataValueDescriptor from the specified ResultSet.

public void
setWidth(int desiredWidth, int desiredScale, boolean errorOnTrunc)

Implements org.apache.derby.iapi.types.VariableSizeDataValue.setWidth.

public int
Inherited from org.apache.derby.iapi.types.SQLBinary:
charLengthcheckHostVariablecloneHoldercomparecompareconcatenateequalsestimateMemoryUsagegetBytesgetLengthgetStreamgetStringgetTraceStringgetValuegreaterOrEqualsgreaterThanhashCodeisNulllessOrEqualslessThanloadStreamnotEqualsobjectNullreadExternalrestoreToNullreturnStreamsetFromsetStreamsetValuesetValuesetValuesubstringtoStringtruncatewriteExternal

Constructor Detail

SQLBlobback to summary
public SQLBlob()
SQLBlobback to summary
public SQLBlob(byte[] val)
SQLBlobback to summary
public SQLBlob(Blob val)

Method Detail

cloneValueback to summary
public DataValueDescriptor cloneValue(boolean forceMaterialization)

Overrides org.apache.derby.iapi.types.SQLBinary.cloneValue.

Implements org.apache.derby.iapi.types.DataValueDescriptor.cloneValue.

Returns a clone of this BLOB value.

Unlike the other binary types, BLOBs can be very large. We try to clone the underlying stream when possible to avoid having to materialize the value into memory.

Parameters
forceMaterialization:boolean

any streams representing the data value will be materialized if true, the data value will be kept as a stream if possible if false

Returns:DataValueDescriptor

A clone of this BLOB value.

getMaxMemoryUsageback to summary
pack-priv int getMaxMemoryUsage()

Implements abstract org.apache.derby.iapi.types.SQLBinary.getMaxMemoryUsage.

Return max memory usage for a SQL Blob

getNewNullback to summary
public DataValueDescriptor getNewNull()

Implements org.apache.derby.iapi.types.DataValueDescriptor.getNewNull.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.getNewNull.

Get a new null value of the same type as this data value.

See Also
DataValueDescriptor#getNewNull
getObjectback to summary
public Object getObject() throws StandardException

Overrides org.apache.derby.iapi.types.DataType.getObject.

Implements org.apache.derby.iapi.types.DataValueDescriptor.getObject.

Return a JDBC Blob. Originally implemented to support DERBY-2201.

Returns:Object

Doc from org.apache.derby.iapi.types.DataValueDescriptor.getObject.

The data value as an Object.

Exceptions
StandardException:

Doc from org.apache.derby.iapi.types.DataValueDescriptor.getObject.

Thrown on error

getTypeFormatIdback to summary
public int getTypeFormatId()

Implements org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

Return my format identifier.

Returns:int

Doc from org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

The identifier. (A UUID stuffed in an array of 16 bytes).

See Also
org.apache.derby.iapi.services.io.TypedFormat#getTypeFormatId
getTypeNameback to summary
public String getTypeName()

Implements org.apache.derby.iapi.types.DataValueDescriptor.getTypeName.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.getTypeName.

Get the SQL name of the datatype

Returns:String

The SQL name of the datatype

hasStreamback to summary
public boolean hasStream()

Overrides org.apache.derby.iapi.types.DataType.hasStream.

Implements org.apache.derby.iapi.types.DataValueDescriptor.hasStream.

Tells if this BLOB value is, or will be, represented by a stream.

Returns:boolean

true if the value is represented by a stream, false otherwise.

isLengthLessback to summary
private final boolean isLengthLess()

Tell if this blob is length less.

Returns:boolean

true if the length of the blob is not known, false otherwise

normalizeback to summary
public void normalize(DataTypeDescriptor desiredType, DataValueDescriptor source) throws StandardException

Overrides org.apache.derby.iapi.types.DataType.normalize.

Implements org.apache.derby.iapi.types.DataValueDescriptor.normalize.

Normalization method - this method may be called when putting a value into a SQLBit, for example, when inserting into a SQLBit column. See NormalizeResultSet in execution.

Parameters
desiredType:DataTypeDescriptor

The type to normalize the source column to

source:DataValueDescriptor

The value to normalize

Exceptions
StandardException:
Thrown for null into non-nullable column, and for truncation error
setIntoback to summary
public void setInto(PreparedStatement ps, int position) throws SQLException, StandardException

Overrides org.apache.derby.iapi.types.SQLBinary.setInto.

Implements org.apache.derby.iapi.types.DataValueDescriptor.setInto.

Doc from org.apache.derby.iapi.types.SQLBinary.setInto.

Adding this method to ensure that super class' setInto method doesn't get called that leads to the violation of JDBC spec( untyped nulls ) when batching is turned on.

Exceptions
SQLException:

Doc from org.apache.derby.iapi.types.DataValueDescriptor.setInto.

thrown by the PreparedStatement object

StandardException:

Doc from org.apache.derby.iapi.types.DataValueDescriptor.setInto.

thrown by me accessing my value.

setObjectback to summary
pack-priv final void setObject(Object theValue) throws StandardException

Overrides org.apache.derby.iapi.types.DataType.setObject.

Set the value from an non-null object.

setValueFromResultSetback to summary
public void setValueFromResultSet(ResultSet resultSet, int colNumber, boolean isNullable) throws SQLException, StandardException

Implements org.apache.derby.iapi.types.DataValueDescriptor.setValueFromResultSet.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.setValueFromResultSet.

Set the value based on the value for the specified DataValueDescriptor from the specified ResultSet.

Parameters
resultSet:ResultSet

The specified ResultSet.

colNumber:int

The 1-based column # into the resultSet.

isNullable:boolean

Whether or not the column is nullable (No need to call wasNull() if not)

Exceptions
SQLException:
Thrown on error
StandardException:
Thrown on error
See Also
DataValueDescriptor#setValueFromResultSet
setWidthback to summary
public void setWidth(int desiredWidth, int desiredScale, boolean errorOnTrunc) throws StandardException

Implements org.apache.derby.iapi.types.VariableSizeDataValue.setWidth.

typePrecedenceback to summary
public int typePrecedence()

Overrides org.apache.derby.iapi.types.DataType.typePrecedence.

Implements org.apache.derby.iapi.types.DataValueDescriptor.typePrecedence.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.typePrecedence.

Each built-in type in JSQL has a precedence. This precedence determines how to do type promotion when using binary operators. For example, float has a higher precedence than int, so when adding an int to a float, the result type is float. The precedence for some types is arbitrary. For example, it doesn't matter what the precedence of the boolean type is, since it can't be mixed with other types. But the precedence for the number types is critical. The SQL standard requires that exact numeric types be promoted to approximate numeric when one operator uses both. Also, the precedence is arranged so that one will not lose precision when promoting a type.

Returns:int

The precedence of this type.

See Also
DataValueDescriptor#typePrecedence