| java.lang.Object com.jcorporate.expresso.core.dataobjects.jdbc.LobField
LobField | public class LobField (Code) | | This class provides a low level BLOB capability while still keeping the
programmer isolated from SQL syntax details.
The general usage is as follows:
MyDBObject myObj.setField("key1",1);
LobField query = new LobField();
query.setCriteria(myObj);
java.io.InputStream inputStream = getBlobStream("blobFieldName");
//Do whatever you want with the stream
inputStream.flush();
inputStream.close();
query.close();
This class requires a JDBC 2 compliant driver for the BLOB/CLOB data types.
Some drivers do not support these features, at which point you'll want
to use the getBlobStream/getClobStream/getClobAsciiStream methods instead
author: Michael Rimov since: $DatabaseSchema $Date: 2004/11/18 02:03:27 $ |
Constructor Summary | |
public | LobField() Default constructor. |
Method Summary | |
public void | close() Close the query resources held by the object. | protected void | finalize() Override of base object finalization to make sure that the database
resources are closed if for some reason they haven't had this done
to them already. | protected void | finalizeUpdate(DBConnection theConnection) | public Blob | getBlob(String fieldName) Retrieves a java.sql.Blob object given the criteria object
set previously. | public InputStream | getBlobStream(String fieldName) Retrieve an input stream for a binary object stored in the database.
Parameters: fieldName - the field name to retrieve. | public Clob | getClob(String fieldName) Retrieves a java.sql.Clob object given the criteria object
set previously. | public InputStream | getClobAsciiStream(String fieldName) Retrieve a java.io.InputStream a.k.a. | public java.io.Reader | getClobStream(String fieldName) Retrieve a java.io.Reader a.k.a Unicode stream for a CLOB field.
Parameters: fieldName - the name of the field to retrieve. | public String | getClobString(String fieldName) CLOB convenience method. | protected JDBCDataObject | getCriteria() | protected void | oraclePrepSelectForUpdate(JDBCDataObject baseObject, String fieldName, DBConnection theConnection) Internal helper function to prepare a BLOB update for Oracle. | protected void | prepSelectResultSet(JDBCDataObject baseObject, String fieldName, DBConnection theConnection) Internal helper function that does the guts of the work
Parameters: baseObject - The object that contains the metadata for this BLOB Parameters: fieldName - the name of the field that is the BLOB field Parameters: theConnection - an already allocated DBConnection object. | protected PreparedStatement | prepUpdate(JDBCDataObject baseObject, String fieldName, DBConnection theConnection) | public void | saveBlob(String fieldName, InputStream data, int dataSize) Saves an InputStream into the database given the criteria and the fieldname
(Criteria should have been previously set).
Parameters: fieldName - The name of the field to save the Stream to. Parameters: data - a java.io.InputStream object to save to the field. | public void | saveBlob(String fieldName, Blob data) Saves a java.sql.Blob to the record matching the criteria
earlier set. | public void | saveClob(String fieldName, InputStream data, int length) Saves an InputStream into the database given the criteria and the fieldname
(Criteria should have been previously set).
Parameters: fieldName - The name of the field to save the Stream to. Parameters: data - a java.io.InputStream object to save to the field. | public void | saveClob(String fieldName, java.io.Reader data, int length) Saves an InputStream into the database given the criteria and the fieldname
(Criteria should have been previously set).
Parameters: fieldName - The name of the field to save the Stream to. Parameters: data - a java.io.Reader object to save to the field. | public void | saveClob(String fieldName, String data) Saves a string to a CLOB field. | public void | saveClob(String fieldName, Clob data) Saves an InputStream into the database given the criteria and the fieldname
(Criteria should have been previously set).
Parameters: fieldName - The name of the field to save the Stream to. Parameters: data - a java.io.Reader object to save to the field. | public void | setCriteria(JDBCDataObject newCriteria) Set the search criteria for the blob. |
alreadyInTransaction | boolean alreadyInTransaction(Code) | | |
criteria | protected JDBCDataObject criteria(Code) | | The dataobject to use to build the SQL search/update statements.
|
LobField | public LobField()(Code) | | Default constructor. Currently does nothing.
|
close | public void close()(Code) | | Close the query resources held by the object. This should be wrapped
in a try/finally block so that database connection resources are not
left floating in limbo.
|
finalize | protected void finalize() throws java.lang.Throwable(Code) | | Override of base object finalization to make sure that the database
resources are closed if for some reason they haven't had this done
to them already.
|
getBlob | public Blob getBlob(String fieldName) throws DataException(Code) | | Retrieves a java.sql.Blob object given the criteria object
set previously.
Parameters: fieldName - the name of the field to retrieve java.sql.Blob for the field throws: DataException - if there is an error finding the object, an errorretrieving the Blob from the system, or other database communicationerrors. |
getBlobStream | public InputStream getBlobStream(String fieldName) throws DataException(Code) | | Retrieve an input stream for a binary object stored in the database.
Parameters: fieldName - the field name to retrieve. java.io.InputStream representing the BLOB object throws: DataException - upon error |
getClob | public Clob getClob(String fieldName) throws DataException(Code) | | Retrieves a java.sql.Clob object given the criteria object
set previously.
Parameters: fieldName - the name of the field to retrieve java.sql.Clob for the field throws: DataException - if there is an error finding the object, an errorretrieving the Clob from the system, or other database communicationerrors. |
getClobAsciiStream | public InputStream getClobAsciiStream(String fieldName) throws DataException(Code) | | Retrieve a java.io.InputStream a.k.a. ASCII stream for a CLOB field.
Parameters: fieldName - the name of the field to retrieve. java.io.Reader for the ASCII CLOB stream stored in the database throws: DataException - upon error retrieving the CLOB |
getClobStream | public java.io.Reader getClobStream(String fieldName) throws DataException(Code) | | Retrieve a java.io.Reader a.k.a Unicode stream for a CLOB field.
Parameters: fieldName - the name of the field to retrieve. java.io.Reader for the Unicode CLOB stream stored in the database throws: DataException - upon error retrieving the CLOB |
getClobString | public String getClobString(String fieldName) throws DataException(Code) | | CLOB convenience method. Reads the entire stream into a string. Note
that if your field is large, this may take large amounts of memory
to perform this operation. It is recommended to use getClobStream()
for most purposes.
Note that this method is not supported by InterBase/InterClient 2 which
does not support Unicode streams. Use getClobAsciiStream instead
Parameters: fieldName - the name of the field to retrieve java.lang.String containing the entire contents of the CLOBfield. throws: DataException - upon error. |
getCriteria | protected JDBCDataObject getCriteria()(Code) | | Protected method to get at the criteria object from any derived classes
JDBCDataObject or null if no criteria has been set |
oraclePrepSelectForUpdate | protected void oraclePrepSelectForUpdate(JDBCDataObject baseObject, String fieldName, DBConnection theConnection) throws DataException(Code) | | Internal helper function to prepare a BLOB update for Oracle.
Updates the record, setting the BLOB to to empty_blob() because inserts without
setting the BLOB will result in a LOB Locator not being present, which will prevent
the BLOB from being added to the record.
Parameters: baseObject - The object that contains the metadata for this BLOB Parameters: fieldName - the name of the field that is the BLOB field Parameters: theConnection - an already allocated DBConnection object throws: DataException - Modify by Yves Henri AMAIZO since: $DatabaseSchema $Date: 2004/11/18 02:03:27 $ |
prepSelectResultSet | protected void prepSelectResultSet(JDBCDataObject baseObject, String fieldName, DBConnection theConnection) throws DataException(Code) | | Internal helper function that does the guts of the work
Parameters: baseObject - The object that contains the metadata for this BLOB Parameters: fieldName - the name of the field that is the BLOB field Parameters: theConnection - an already allocated DBConnection object. Thisfunction modifies the state of theConnection by allocating a preparedstatement throws: DataException - upon errorModify by Yves Henri AMAIZO since: $DatabaseSchema $Date: 2004/11/18 02:03:27 $ |
prepUpdate | protected PreparedStatement prepUpdate(JDBCDataObject baseObject, String fieldName, DBConnection theConnection) throws DataException(Code) | | Internal helper function to prepare a LOB update
Parameters: baseObject - The object that contains the metadata for this BLOB Parameters: fieldName - the name of the field that is the BLOB field Parameters: theConnection - an already allocated DBConnection object a created PreparedStatement object throws: DataException - Modify by Yves Henri AMAIZO since: $DatabaseSchema $Date: 2004/11/18 02:03:27 $ |
saveBlob | public void saveBlob(String fieldName, InputStream data, int dataSize) throws DataException(Code) | | Saves an InputStream into the database given the criteria and the fieldname
(Criteria should have been previously set).
Parameters: fieldName - The name of the field to save the Stream to. Parameters: data - a java.io.InputStream object to save to the field. May be nullif you want the field to be null. Parameters: dataSize - the length of the stream to save. throws: DataException - upon database communications error. throws: IllegalArgumentException - if fieldName is null. |
saveBlob | public void saveBlob(String fieldName, Blob data) throws DataException(Code) | | Saves a java.sql.Blob to the record matching the criteria
earlier set.
Parameters: fieldName - the name of the field to save to Parameters: data - the java.sql.Blob based object to save to thedatabase. throws: DataException - upon database communication error throws: IllegalArgumentException - if data is null |
saveClob | public void saveClob(String fieldName, InputStream data, int length) throws DataException(Code) | | Saves an InputStream into the database given the criteria and the fieldname
(Criteria should have been previously set).
Parameters: fieldName - The name of the field to save the Stream to. Parameters: data - a java.io.InputStream object to save to the field. May be nullif you want the field to be null. Parameters: length - The size of the CLOB stream to save to the database throws: IllegalArgumentException - if fieldName is null. throws: DataException - upon database communications error. |
saveClob | public void saveClob(String fieldName, java.io.Reader data, int length) throws DataException(Code) | | Saves an InputStream into the database given the criteria and the fieldname
(Criteria should have been previously set).
Parameters: fieldName - The name of the field to save the Stream to. Parameters: data - a java.io.Reader object to save to the field. May be nullif you want the field to be null. Parameters: length - The size of the data stream to save to the database throws: DataException - upon database communications error. throws: IllegalArgumentException - if fieldName is null. |
saveClob | public void saveClob(String fieldName, String data) throws DataException(Code) | | Saves a string to a CLOB field.
Parameters: fieldName - the name of the field to save to. Parameters: data - the String value to save to the field. throws: DataException - upon error |
saveClob | public void saveClob(String fieldName, Clob data) throws DataException(Code) | | Saves an InputStream into the database given the criteria and the fieldname
(Criteria should have been previously set).
Parameters: fieldName - The name of the field to save the Stream to. Parameters: data - a java.io.Reader object to save to the field. May be nullif you want the field to be null. throws: DataException - upon database communications error. throws: IllegalArgumentException - if fieldName is null. |
setCriteria | public void setCriteria(JDBCDataObject newCriteria) throws DataException(Code) | | Set the search criteria for the blob. All key fields must be present
as this does a full retrieve() rather than a search on the data. Otherwise
the object will throw an exception .
Parameters: newCriteria - a filled out JDBCObject (DBObject derived classes work)with all keys present throws: DataException - if all keys are not present. |
|
|