Top Description Constructors Methods
org.apache.derby.impl.jdbc

public Class LOBStoredProcedure

extends Object
Class Inheritance
Imports
java.sql.Blob, .Clob, .SQLException, org.apache.derby.iapi.jdbc.EngineLOB, .InternalDriver, org.apache.derby.shared.common.reference.Limits, .SQLState

Contains the stored procedures that will be used in the LOB client side methods.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static int

Returns:

an integer that maps to the Blob value created.
BLOBCREATELOCATOR
()

Creates a new empty Blob and registers it in the HashMap in the Connection and returns the locator value corresponding to this Blob.

public static byte[]

Returns:

A byte array containing the bytes read, starting from position pos in the Blob.
BLOBGETBYTES
(int
the locator value of the Blob from which the byte array needs to be retrieved.
LOCATOR
,
long
the position from which the bytes from the Blob need to be retrieved.
pos
,
int
the maximum number of bytes to read. The value will be reduced to the maximum allowed return length if required (see Limits#MAX_BLOB_RETURN_LEN).
len
)

Reads up to len bytes from the associated Blob and returns a byte array containing the bytes read.

public static long

Returns:

the length of the Blob object mapped to the locator .
BLOBGETLENGTH
(int
the locator value of the Blob whose length needs to be found.
LOCATOR
)

Returns the length in bytes of the Blob.

public static long

Returns:

the position at which the first occurrence of the Byte array is found.
BLOBGETPOSITIONFROMBYTES
(int
the locator value of the Blob in which the seaching needs to be done.
LOCATOR
,
byte[]
the byte array whose position needs needs to be found.
searchBytes
,
long
the position from which the seaching needs to be done.
pos
)

Returns the first occurrence of the byte array in the Blob.

public static long

Returns:

the position at which the first occurrence of the Blob is found.
BLOBGETPOSITIONFROMLOCATOR
(int
the locator value of the Blob in which the seaching needs to be done.
LOCATOR
,
int
the locator value of the Blob whose position needs needs to be found.
searchLocator
,
long
the position from which the seaching needs to be done.
pos
)

Returns the first occurrence of locator in the Blob.

public static void
BLOBRELEASELOCATOR(int
an integer that represents the locator that needs to be removed from the hash map.
LOCATOR
)

Removes the supplied LOCATOR entry from the hash map.

public static void
BLOBSETBYTES(int
the integer that represents the Blob in which the bytes need to be replaced.
LOCATOR
,
long
the position stating from which the byte replacement needs to happen.
pos
,
int
the number of bytes that need to be used in replacement.
len
,
byte[]
the byte array that contains the bytes that needs to be used for replacement.
replaceBytes
)

Replaces the bytes at pos with len bytes

public static void
BLOBTRUNCATE(int
an integer that represents the LOCATOR used to retrieve an instance of the LOB.
LOCATOR
,
long
an integer that represents the length to which the Blob must be truncated to.
length
)

truncates the Blob value represented by LOCATOR to have a length of length.

public static int

Returns:

an integer that maps to the Clob value created.
CLOBCREATELOCATOR
()

Creates a new empty Clob and registers it in the HashMap in the Connection and returns the locator value corresponding to this Clob.

public static long

Returns:

an integer that represents the length of the Clob.
CLOBGETLENGTH
(int
an integer that represents the locator of the Clob whose length needs to be obtained.
LOCATOR
)

returns the length of the Clob corresponding to the LOCATOR value.

public static long

Returns:

an integer that represents the position inside the Clob of the first occurrence of the sub-string from the given starting position.
CLOBGETPOSITIONFROMLOCATOR
(int
an integer that represents the locator of the Clob in which the given position of the given sub-string needs to be found.
LOCATOR
,
int
a Locator representing a Clob whose occurence inside the Clob needs to be found starting from pos.
searchLocator
,
long
an integer that represents the position inside the Clob from which the search needs to begin.
fromPosition
)

returns the first occurrence of the given search string from the given start search position inside the Clob.

public static long

Returns:

an integer that represents the position inside the Clob of the first occurrence of the sub-string from the given starting position.
CLOBGETPOSITIONFROMSTRING
(int
an integer that represents the locator of the Clob in which the given position of the given sub-string needs to be found.
LOCATOR
,
String
a String whose occurence inside the Clob needs to be found starting from pos.
searchLiteral
,
long
an integer that represents the position inside the Clob from which the search needs to begin.
fromPosition
)

returns the first occurrence of the given search string from the given start search position inside the Clob.

public static String

Returns:

A substring from the Clob starting at the given position, not longer than len characters.
CLOBGETSUBSTRING
(int
an integer that represents the LOCATOR used to retrieve an instance of the LOB.
LOCATOR
,
long
a long that represents the position from which the substring begins.
pos
,
int
an integer representing the maximum length of the substring. The value will be reduced to the maximum allowed return length if required (see Limits#MAX_CLOB_RETURN_LEN).
len
)

Returns the String starting from pos and consisting of up to len consecutive characters from the Clob corresponding to LOCATOR.

public static void
CLOBRELEASELOCATOR(int
an integer that represents the locator that needs to be removed from the hash map.
LOCATOR
)

Removes the supplied LOCATOR entry from the hash map.

public static void
CLOBSETSTRING(int
an integer that represents the locator of the Clob in which the characters need to be replaced.
LOCATOR
,
long
an integer that represents the position inside the Clob from which the string needs to be replaced.
pos
,
int
the number of characters from the string that need to be used for replacement.
length
,
String
the string from which the repalcement characters are built.
str
)

replaces the characters starting at fromPosition and with length ForLength

public static void
CLOBTRUNCATE(int
an integer that represents the LOCATOR used to retrieve an instance of the LOB.
LOCATOR
,
long
an integer that represents the length to which the Clob must be truncated to.
length
)

truncates the Clob value represented by LOCATOR to have a length of length.

private static Blob

Returns:

a Blob object that is mapped to the LOCATOR object passed in.
getBlobObjectCorrespondingtoLOCATOR
(int
an integer that represents the locator corresponding to the Blob object requested.
LOCATOR
)

returns the Blob object corresponding to the locator.

private static Clob

Returns:

a Clob object that is mapped to the LOCATOR object passed in.
getClobObjectCorrespondingtoLOCATOR
(int
an integer that represents the locator corresponding to the Clob object requested.
LOCATOR
)

returns the Clob object corresponding to the locator.

private static EmbedConnection
getEmbedConnection()

Returns the EmbedConnection object.

private static SQLException

Returns:

a SQLEXception.
newSQLException
(String
The messageId of the message associated with this message.
messageId
)

Generate the SQLException with the appropriate SQLState.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

LOBStoredProcedureback to summary
public LOBStoredProcedure()

Method Detail

BLOBCREATELOCATORback to summary
public static int BLOBCREATELOCATOR() throws SQLException

Creates a new empty Blob and registers it in the HashMap in the Connection and returns the locator value corresponding to this Blob.

Returns:int

an integer that maps to the Blob value created.

BLOBGETBYTESback to summary
public static byte[] BLOBGETBYTES(int LOCATOR, long pos, int len) throws SQLException

Reads up to len bytes from the associated Blob and returns a byte array containing the bytes read.

Note that a smaller number of bytes than requested might be returned. The number of bytes returned can be found by checking the length of the returned byte array.

Parameters
LOCATOR:int

the locator value of the Blob from which the byte array needs to be retrieved.

pos:long

the position from which the bytes from the Blob need to be retrieved.

len:int

the maximum number of bytes to read. The value will be reduced to the maximum allowed return length if required (see Limits#MAX_BLOB_RETURN_LEN).

Returns:byte[]

A byte array containing the bytes read, starting from position pos in the Blob.

BLOBGETLENGTHback to summary
public static long BLOBGETLENGTH(int LOCATOR) throws SQLException

Returns the length in bytes of the Blob.

Parameters
LOCATOR:int

the locator value of the Blob whose length needs to be found.

Returns:long

the length of the Blob object mapped to the locator .

BLOBGETPOSITIONFROMBYTESback to summary
public static long BLOBGETPOSITIONFROMBYTES(int LOCATOR, byte[] searchBytes, long pos) throws SQLException

Returns the first occurrence of the byte array in the Blob.

Parameters
LOCATOR:int

the locator value of the Blob in which the seaching needs to be done.

searchBytes:byte[]

the byte array whose position needs needs to be found.

pos:long

the position from which the seaching needs to be done.

Returns:long

the position at which the first occurrence of the Byte array is found.

BLOBGETPOSITIONFROMLOCATORback to summary
public static long BLOBGETPOSITIONFROMLOCATOR(int LOCATOR, int searchLocator, long pos) throws SQLException

Returns the first occurrence of locator in the Blob.

Parameters
LOCATOR:int

the locator value of the Blob in which the seaching needs to be done.

searchLocator:int

the locator value of the Blob whose position needs needs to be found.

pos:long

the position from which the seaching needs to be done.

Returns:long

the position at which the first occurrence of the Blob is found.

BLOBRELEASELOCATORback to summary
public static void BLOBRELEASELOCATOR(int LOCATOR) throws SQLException

Removes the supplied LOCATOR entry from the hash map.

Parameters
LOCATOR:int

an integer that represents the locator that needs to be removed from the hash map.

BLOBSETBYTESback to summary
public static void BLOBSETBYTES(int LOCATOR, long pos, int len, byte[] replaceBytes) throws SQLException

Replaces the bytes at pos with len bytes

Parameters
LOCATOR:int

the integer that represents the Blob in which the bytes need to be replaced.

pos:long

the position stating from which the byte replacement needs to happen.

len:int

the number of bytes that need to be used in replacement.

replaceBytes:byte[]

the byte array that contains the bytes that needs to be used for replacement.

BLOBTRUNCATEback to summary
public static void BLOBTRUNCATE(int LOCATOR, long length) throws SQLException

truncates the Blob value represented by LOCATOR to have a length of length.

Parameters
LOCATOR:int

an integer that represents the LOCATOR used to retrieve an instance of the LOB.

length:long

an integer that represents the length to which the Blob must be truncated to.

CLOBCREATELOCATORback to summary
public static int CLOBCREATELOCATOR() throws SQLException

Creates a new empty Clob and registers it in the HashMap in the Connection and returns the locator value corresponding to this Clob.

Returns:int

an integer that maps to the Clob value created.

CLOBGETLENGTHback to summary
public static long CLOBGETLENGTH(int LOCATOR) throws SQLException

returns the length of the Clob corresponding to the LOCATOR value.

Parameters
LOCATOR:int

an integer that represents the locator of the Clob whose length needs to be obtained.

Returns:long

an integer that represents the length of the Clob.

CLOBGETPOSITIONFROMLOCATORback to summary
public static long CLOBGETPOSITIONFROMLOCATOR(int LOCATOR, int searchLocator, long fromPosition) throws SQLException

returns the first occurrence of the given search string from the given start search position inside the Clob.

Parameters
LOCATOR:int

an integer that represents the locator of the Clob in which the given position of the given sub-string needs to be found.

searchLocator:int

a Locator representing a Clob whose occurence inside the Clob needs to be found starting from pos.

fromPosition:long

an integer that represents the position inside the Clob from which the search needs to begin.

Returns:long

an integer that represents the position inside the Clob of the first occurrence of the sub-string from the given starting position.

CLOBGETPOSITIONFROMSTRINGback to summary
public static long CLOBGETPOSITIONFROMSTRING(int LOCATOR, String searchLiteral, long fromPosition) throws SQLException

returns the first occurrence of the given search string from the given start search position inside the Clob.

Parameters
LOCATOR:int

an integer that represents the locator of the Clob in which the given position of the given sub-string needs to be found.

searchLiteral:String

a String whose occurence inside the Clob needs to be found starting from pos.

fromPosition:long

an integer that represents the position inside the Clob from which the search needs to begin.

Returns:long

an integer that represents the position inside the Clob of the first occurrence of the sub-string from the given starting position.

CLOBGETSUBSTRINGback to summary
public static String CLOBGETSUBSTRING(int LOCATOR, long pos, int len) throws SQLException

Returns the String starting from pos and consisting of up to len consecutive characters from the Clob corresponding to LOCATOR.

Parameters
LOCATOR:int

an integer that represents the LOCATOR used to retrieve an instance of the LOB.

pos:long

a long that represents the position from which the substring begins.

len:int

an integer representing the maximum length of the substring. The value will be reduced to the maximum allowed return length if required (see Limits#MAX_CLOB_RETURN_LEN).

Returns:String

A substring from the Clob starting at the given position, not longer than len characters.

CLOBRELEASELOCATORback to summary
public static void CLOBRELEASELOCATOR(int LOCATOR) throws SQLException

Removes the supplied LOCATOR entry from the hash map.

Parameters
LOCATOR:int

an integer that represents the locator that needs to be removed from the hash map.

CLOBSETSTRINGback to summary
public static void CLOBSETSTRING(int LOCATOR, long pos, int length, String str) throws SQLException

replaces the characters starting at fromPosition and with length ForLength

Parameters
LOCATOR:int

an integer that represents the locator of the Clob in which the characters need to be replaced.

pos:long

an integer that represents the position inside the Clob from which the string needs to be replaced.

length:int

the number of characters from the string that need to be used for replacement.

str:String

the string from which the repalcement characters are built.

CLOBTRUNCATEback to summary
public static void CLOBTRUNCATE(int LOCATOR, long length) throws SQLException

truncates the Clob value represented by LOCATOR to have a length of length.

Parameters
LOCATOR:int

an integer that represents the LOCATOR used to retrieve an instance of the LOB.

length:long

an integer that represents the length to which the Clob must be truncated to.

getBlobObjectCorrespondingtoLOCATORback to summary
private static Blob getBlobObjectCorrespondingtoLOCATOR(int LOCATOR) throws SQLException

returns the Blob object corresponding to the locator.

Parameters
LOCATOR:int

an integer that represents the locator corresponding to the Blob object requested.

Returns:Blob

a Blob object that is mapped to the LOCATOR object passed in.

getClobObjectCorrespondingtoLOCATORback to summary
private static Clob getClobObjectCorrespondingtoLOCATOR(int LOCATOR) throws SQLException

returns the Clob object corresponding to the locator.

Parameters
LOCATOR:int

an integer that represents the locator corresponding to the Clob object requested.

Returns:Clob

a Clob object that is mapped to the LOCATOR object passed in.

Exceptions
SQLException:
on error
getEmbedConnectionback to summary
private static EmbedConnection getEmbedConnection() throws SQLException

Returns the EmbedConnection object.

newSQLExceptionback to summary
private static SQLException newSQLException(String messageId)

Generate the SQLException with the appropriate SQLState.

Parameters
messageId:String

The messageId of the message associated with this message.

Returns:SQLException

a SQLEXception.