|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.jcorporate.expresso.core.dataobjects.jdbc.LobField
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
| Field Summary | |
protected JDBCDataObject |
criteria
The dataobject to use to build the SQL search/update statements. |
protected DBConnection |
myConnection
|
| Constructor Summary | |
LobField()
Default constructor. |
|
| Method Summary | |
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)
|
Blob |
getBlob(String fieldName)
Retrieves a java.sql.Blob object given the criteria object
set previously. |
InputStream |
getBlobStream(String fieldName)
Retrieve an input stream for a binary object stored in the database. |
Clob |
getClob(String fieldName)
Retrieves a java.sql.Clob object given the criteria object
set previously. |
InputStream |
getClobAsciiStream(String fieldName)
Retrieve a java.io.InputStream a.k.a. |
Reader |
getClobStream(String fieldName)
Retrieve a java.io.Reader a.k.a Unicode stream for a CLOB field. |
String |
getClobString(String fieldName)
CLOB convenience method. |
protected JDBCDataObject |
getCriteria()
Protected method to get at the criteria object from any derived classes |
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 |
protected PreparedStatement |
prepUpdate(JDBCDataObject baseObject,
String fieldName,
DBConnection theConnection)
Internal helper function to prepare a LOB update |
void |
saveBlob(String fieldName,
Blob data)
Saves a java.sql.Blob to the record matching the criteria
earlier set. |
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). |
void |
saveClob(String fieldName,
Clob data)
Saves an InputStream into the database given the criteria and the fieldname (Criteria should have been previously set). |
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). |
void |
saveClob(String fieldName,
Reader data,
int length)
Saves an InputStream into the database given the criteria and the fieldname (Criteria should have been previously set). |
void |
saveClob(String fieldName,
String data)
Saves a string to a CLOB field. |
void |
setCriteria(JDBCDataObject newCriteria)
Set the search criteria for the blob. |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected JDBCDataObject criteria
protected DBConnection myConnection
| Constructor Detail |
public LobField()
| Method Detail |
public void setCriteria(JDBCDataObject newCriteria)
throws DataException
newCriteria - a filled out JDBCObject (DBObject derived classes work)
with all keys present
DataException - if all keys are not present.protected JDBCDataObject getCriteria()
public Blob getBlob(String fieldName)
throws DataException
java.sql.Blob object given the criteria object
set previously.
fieldName - the name of the field to retrieve
DataException - if there is an error finding the object, an error
retrieving the Blob from the system, or other database communication
errors.
public Clob getClob(String fieldName)
throws DataException
java.sql.Clob object given the criteria object
set previously.
fieldName - the name of the field to retrieve
DataException - if there is an error finding the object, an error
retrieving the Clob from the system, or other database communication
errors.
public InputStream getBlobStream(String fieldName)
throws DataException
fieldName - the field name to retrieve.
DataException - upon error
public Reader getClobStream(String fieldName)
throws DataException
fieldName - the name of the field to retrieve.
DataException - upon error retrieving the CLOB
public String getClobString(String fieldName)
throws DataException
Note that this method is not supported by InterBase/InterClient 2 which does not support Unicode streams. Use getClobAsciiStream instead
fieldName - the name of the field to retrieve
DataException - upon error.
public InputStream getClobAsciiStream(String fieldName)
throws DataException
fieldName - the name of the field to retrieve.
DataException - upon error retrieving the CLOB
public void saveBlob(String fieldName,
InputStream data,
int dataSize)
throws DataException
fieldName - The name of the field to save the Stream to.data - a java.io.InputStream object to save to the field. May be null
if you want the field to be null.dataSize - the length of the stream to save.
DataException - upon database communications error.
IllegalArgumentException - if fieldName is null.
public void saveBlob(String fieldName,
Blob data)
throws DataException
java.sql.Blob to the record matching the criteria
earlier set.
fieldName - the name of the field to save todata - the java.sql.Blob based object to save to the
database.
DataException - upon database communication error
IllegalArgumentException - if data is null
public void saveClob(String fieldName,
InputStream data,
int length)
throws DataException
fieldName - The name of the field to save the Stream to.data - a java.io.InputStream object to save to the field. May be null
if you want the field to be null.length - The size of the CLOB stream to save to the database
IllegalArgumentException - if fieldName is null.
DataException - upon database communications error.
public void saveClob(String fieldName,
Reader data,
int length)
throws DataException
fieldName - The name of the field to save the Stream to.data - a java.io.Reader object to save to the field. May be null
if you want the field to be null.length - The size of the data stream to save to the database
DataException - upon database communications error.
IllegalArgumentException - if fieldName is null.
public void saveClob(String fieldName,
String data)
throws DataException
fieldName - the name of the field to save to.data - the String value to save to the field.
DataException - upon error
public void saveClob(String fieldName,
Clob data)
throws DataException
fieldName - The name of the field to save the Stream to.data - a java.io.Reader object to save to the field. May be null
if you want the field to be null.
DataException - upon database communications error.
IllegalArgumentException - if fieldName is null.public void close()
protected void finalize()
throws Throwable
Throwable
protected void prepSelectResultSet(JDBCDataObject baseObject,
String fieldName,
DBConnection theConnection)
throws DataException
baseObject - The object that contains the metadata for this BLOBfieldName - the name of the field that is the BLOB fieldtheConnection - an already allocated DBConnection object. This
function modifies the state of theConnection by allocating a prepared
statement
DataException - upon error
Modify by Yves Henri AMAIZO
protected PreparedStatement prepUpdate(JDBCDataObject baseObject,
String fieldName,
DBConnection theConnection)
throws DataException
baseObject - The object that contains the metadata for this BLOBfieldName - the name of the field that is the BLOB fieldtheConnection - an already allocated DBConnection object
DataException - Modify by Yves Henri AMAIZO
protected void finalizeUpdate(DBConnection theConnection)
throws DataException
DataException
protected void oraclePrepSelectForUpdate(JDBCDataObject baseObject,
String fieldName,
DBConnection theConnection)
throws DataException
baseObject - The object that contains the metadata for this BLOBfieldName - the name of the field that is the BLOB fieldtheConnection - an already allocated DBConnection object
DataException - Modify by Yves Henri AMAIZO
|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||