Java Reference
In-Depth Information
Table 4-6: SQL3 Data Type Reference Methods
SQL3 type
get
set
update
BLOB
getBlob
seBlob
updateBlob
CLOB
getClob
setClob
updateClob
ARRAY
getArray
setArray
updateArray
Structured type
getObject
setObject
updateObject
REF ( structured type)
getObject
setObject
updateObject
At the time of this writing, the update methods are scheduled for future
release. Until then, you can use the method updateObject, which works
just as well.
Note
Here's an example of accessing one of these new data types. The following code
fragment retrieves a CLOB value, Notes, from a patient's medical records.
ResultSet rs = stmt.executeQuery(
"SELECT Notes FROM Patients WHERE SSN = 123-45-6789");
rs.next();
Clob notes = rs.getClob("Notes");
Because a SQL BLOB, CLOB, or ARRAY object may be very large, an instance of
any o f these types is actually a SQL locator or logical pointer to the object in the
database that the instance represents. JDBC provides the tools to manipulate them
without having to bring all of their data from the database server to your client
machine. This feature can make performance significantly faster.
If you want to bring the data of a BLOB or CLOB value to the client, you can use the
following methods in the Blob and Clob interfaces provided for this purpose:
 
getAsciiStream()(Gets the CLOB value designated by this Clob object as a stream of ASCII
bytes)
 
getCharacterStream() (Gets the Clob contents as a Unicode stream)
 
getSubString(long pos, int length)(Returns a copy of the specified substring in the CLOB value
designated by this Clob object)
 
length()(Returns the number of characters in the CLOB value designated by this Clob object)
 
position(Clob searchstr, long start) (Determines the character position at which the specified
Clob object searchstr appears in this Clob object)
 
position(String searchstr, long start) (Determines the character position at which the specified
substring searchstr appears in the CLOB)
Search WWH ::




Custom Search