|
|||||||||
| Home >> All >> com >> jcorporate >> expresso >> core >> dataobjects >> [ jdbc overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.jcorporate.expresso.core.dataobjects.jdbc
Class LobField

java.lang.Objectcom.jcorporate.expresso.core.dataobjects.jdbc.LobField
- public class LobField
- extends java.lang.Object
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
- Since:
- $DatabaseSchema $Date: 2004/11/18 02:03:27 $
| Field Summary | |
(package private) boolean |
alreadyInTransaction
|
protected JDBCDataObject |
criteria
The dataobject to use to build the SQL search/update statements. |
private org.apache.log4j.Logger |
log
The log4j Logger to use. |
protected com.jcorporate.expresso.core.db.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(com.jcorporate.expresso.core.db.DBConnection theConnection)
|
private java.sql.Blob |
getBLOB(JDBCDataObject baseObject,
java.lang.String fieldName,
com.jcorporate.expresso.core.db.DBConnection theConnection)
Returns a single stream for a LOB object. |
java.sql.Blob |
getBlob(java.lang.String fieldName)
Retrieves a java.sql.Blob object given the criteria object
set previously. |
java.io.InputStream |
getBlobStream(java.lang.String fieldName)
Retrieve an input stream for a binary object stored in the database. |
private java.sql.Clob |
getCLOB(JDBCDataObject baseObject,
java.lang.String fieldName,
com.jcorporate.expresso.core.db.DBConnection theConnection)
Retrieves the CLOB data for the specified DBObject and the specified fieldName |
java.sql.Clob |
getClob(java.lang.String fieldName)
Retrieves a java.sql.Clob object given the criteria object
set previously. |
java.io.InputStream |
getClobAsciiStream(java.lang.String fieldName)
Retrieve a java.io.InputStream a.k.a. |
private java.io.Reader |
getCLOBReader(JDBCDataObject baseObject,
java.lang.String fieldName,
com.jcorporate.expresso.core.db.DBConnection theConnection)
Retrieves the CLOB data for the specified DBObject and the specified fieldName |
java.io.Reader |
getClobStream(java.lang.String fieldName)
Retrieve a java.io.Reader a.k.a Unicode stream for a CLOB field. |
java.lang.String |
getClobString(java.lang.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,
java.lang.String fieldName,
com.jcorporate.expresso.core.db.DBConnection theConnection)
Internal helper function to prepare a BLOB update for Oracle. |
private void |
oraclePrepUpdateEmptyLob(JDBCDataObject baseObject,
java.lang.String fieldName,
com.jcorporate.expresso.core.db.DBConnection theConnection)
Internal helper function to prepare a LOB update for Oracle. |
private void |
oraclePrepUpdateNullClob(JDBCDataObject baseObject,
java.lang.String fieldName,
com.jcorporate.expresso.core.db.DBConnection theConnection)
Internal helper function to prepare a BLOB update for Oracle. |
private void |
oracleSaveBlob(java.lang.String fieldName,
java.io.InputStream data,
int dataSize)
Saves an InputStream into the database given the criteria and the fieldname (Criteria should have been previously set). |
private void |
oracleSaveClob(java.lang.String fieldName,
java.io.InputStream data,
int length)
Saves an InputStream into the database given the criteria and the fieldname (Criteria should have been previously set). |
private void |
oracleSaveClob(java.lang.String fieldName,
java.io.Reader data,
int length)
Saves a Reader into the database given the criteria and the fieldname Specific to Oracle. |
protected void |
prepSelectResultSet(JDBCDataObject baseObject,
java.lang.String fieldName,
com.jcorporate.expresso.core.db.DBConnection theConnection)
Internal helper function that does the guts of the work |
protected java.sql.PreparedStatement |
prepUpdate(JDBCDataObject baseObject,
java.lang.String fieldName,
com.jcorporate.expresso.core.db.DBConnection theConnection)
Internal helper function to prepare a LOB update |
void |
saveBlob(java.lang.String fieldName,
java.sql.Blob data)
Saves a java.sql.Blob to the record matching the criteria
earlier set. |
void |
saveBlob(java.lang.String fieldName,
java.io.InputStream data,
int dataSize)
Saves an InputStream into the database given the criteria and the fieldname (Criteria should have been previously set). |
void |
saveClob(java.lang.String fieldName,
java.sql.Clob data)
Saves an InputStream into the database given the criteria and the fieldname (Criteria should have been previously set). |
void |
saveClob(java.lang.String fieldName,
java.io.InputStream data,
int length)
Saves an InputStream into the database given the criteria and the fieldname (Criteria should have been previously set). |
void |
saveClob(java.lang.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). |
void |
saveClob(java.lang.String fieldName,
java.lang.String data)
Saves a string to a CLOB field. |
private void |
setBLOB(JDBCDataObject baseObject,
java.lang.String fieldName,
java.io.InputStream theData,
int dataLength,
com.jcorporate.expresso.core.db.DBConnection theConnection)
Updates the underlying table with a BLOB object. |
private void |
setCLOB(JDBCDataObject baseObject,
java.lang.String fieldName,
java.lang.String theData,
com.jcorporate.expresso.core.db.DBConnection theConnection)
Writes a LONG Character string to the database. |
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 |
criteria
protected JDBCDataObject criteria
- The dataobject to use to build the SQL search/update statements.
log
private org.apache.log4j.Logger log
- The log4j Logger to use.
alreadyInTransaction
boolean alreadyInTransaction
myConnection
protected com.jcorporate.expresso.core.db.DBConnection myConnection
| Constructor Detail |
LobField
public LobField()
- Default constructor. Currently does nothing.
| Method Detail |
setCriteria
public void setCriteria(JDBCDataObject newCriteria) throws com.jcorporate.expresso.core.dataobjects.DataException
- 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 .
getCriteria
protected JDBCDataObject getCriteria()
- Protected method to get at the criteria object from any derived classes
getBlob
public java.sql.Blob getBlob(java.lang.String fieldName) throws com.jcorporate.expresso.core.dataobjects.DataException
- Retrieves a
java.sql.Blobobject given the criteria object set previously.
getClob
public java.sql.Clob getClob(java.lang.String fieldName) throws com.jcorporate.expresso.core.dataobjects.DataException
- Retrieves a
java.sql.Clobobject given the criteria object set previously.
getBlobStream
public java.io.InputStream getBlobStream(java.lang.String fieldName) throws com.jcorporate.expresso.core.dataobjects.DataException
- Retrieve an input stream for a binary object stored in the database.
getClobStream
public java.io.Reader getClobStream(java.lang.String fieldName) throws com.jcorporate.expresso.core.dataobjects.DataException
- Retrieve a java.io.Reader a.k.a Unicode stream for a CLOB field.
getClobString
public java.lang.String getClobString(java.lang.String fieldName) throws com.jcorporate.expresso.core.dataobjects.DataException
- 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
getClobAsciiStream
public java.io.InputStream getClobAsciiStream(java.lang.String fieldName) throws com.jcorporate.expresso.core.dataobjects.DataException
- Retrieve a java.io.InputStream a.k.a. ASCII stream for a CLOB field.
saveBlob
public void saveBlob(java.lang.String fieldName, java.io.InputStream data, int dataSize) throws com.jcorporate.expresso.core.dataobjects.DataException
- Saves an InputStream into the database given the criteria and the fieldname
(Criteria should have been previously set).
saveBlob
public void saveBlob(java.lang.String fieldName, java.sql.Blob data) throws com.jcorporate.expresso.core.dataobjects.DataException
- Saves a
java.sql.Blobto the record matching the criteria earlier set.
saveClob
public void saveClob(java.lang.String fieldName, java.io.InputStream data, int length) throws com.jcorporate.expresso.core.dataobjects.DataException
- Saves an InputStream into the database given the criteria and the fieldname
(Criteria should have been previously set).
saveClob
public void saveClob(java.lang.String fieldName, java.io.Reader data, int length) throws com.jcorporate.expresso.core.dataobjects.DataException
- Saves an InputStream into the database given the criteria and the fieldname
(Criteria should have been previously set).
saveClob
public void saveClob(java.lang.String fieldName, java.lang.String data) throws com.jcorporate.expresso.core.dataobjects.DataException
- Saves a string to a CLOB field.
saveClob
public void saveClob(java.lang.String fieldName, java.sql.Clob data) throws com.jcorporate.expresso.core.dataobjects.DataException
- Saves an InputStream into the database given the criteria and the fieldname
(Criteria should have been previously set).
close
public void close()
- 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
- 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.
getCLOB
private java.sql.Clob getCLOB(JDBCDataObject baseObject, java.lang.String fieldName, com.jcorporate.expresso.core.db.DBConnection theConnection) throws com.jcorporate.expresso.core.dataobjects.DataException
- Retrieves the CLOB data for the specified DBObject and the specified
fieldName
getCLOBReader
private java.io.Reader getCLOBReader(JDBCDataObject baseObject, java.lang.String fieldName, com.jcorporate.expresso.core.db.DBConnection theConnection) throws com.jcorporate.expresso.core.dataobjects.DataException
- Retrieves the CLOB data for the specified DBObject and the specified
fieldName
getBLOB
private java.sql.Blob getBLOB(JDBCDataObject baseObject, java.lang.String fieldName, com.jcorporate.expresso.core.db.DBConnection theConnection) throws com.jcorporate.expresso.core.dataobjects.DataException
- Returns a single stream for a LOB object. This single LOB object is
not wrapped by any javax.activation code and therefore is strictly up to
the code creator on how to use the Input Stream.
prepSelectResultSet
protected void prepSelectResultSet(JDBCDataObject baseObject, java.lang.String fieldName, com.jcorporate.expresso.core.db.DBConnection theConnection) throws com.jcorporate.expresso.core.dataobjects.DataException
- Internal helper function that does the guts of the work
- Since:
- $DatabaseSchema $Date: 2004/11/18 02:03:27 $
prepUpdate
protected java.sql.PreparedStatement prepUpdate(JDBCDataObject baseObject, java.lang.String fieldName, com.jcorporate.expresso.core.db.DBConnection theConnection) throws com.jcorporate.expresso.core.dataobjects.DataException
- Internal helper function to prepare a LOB update
- Since:
- $DatabaseSchema $Date: 2004/11/18 02:03:27 $
finalizeUpdate
protected void finalizeUpdate(com.jcorporate.expresso.core.db.DBConnection theConnection) throws com.jcorporate.expresso.core.dataobjects.DataException
setBLOB
private void setBLOB(JDBCDataObject baseObject, java.lang.String fieldName, java.io.InputStream theData, int dataLength, com.jcorporate.expresso.core.db.DBConnection theConnection) throws com.jcorporate.expresso.core.db.DBException
- Updates the underlying table with a BLOB object. Same as the byte[] method
but uses InputStreams intead
setCLOB
private void setCLOB(JDBCDataObject baseObject, java.lang.String fieldName, java.lang.String theData, com.jcorporate.expresso.core.db.DBConnection theConnection) throws com.jcorporate.expresso.core.db.DBException
- Writes a LONG Character string to the database.
oracleSaveBlob
private void oracleSaveBlob(java.lang.String fieldName, java.io.InputStream data, int dataSize) throws com.jcorporate.expresso.core.dataobjects.DataException
- Saves an InputStream into the database given the criteria and the fieldname
(Criteria should have been previously set).
Specific to Oracle. Oracle (as of 9.2) does not support standard jdbc LOB
functionality.
oracleSaveClob
private void oracleSaveClob(java.lang.String fieldName, java.io.InputStream data, int length) throws com.jcorporate.expresso.core.dataobjects.DataException
- Saves an InputStream into the database given the criteria and the fieldname
(Criteria should have been previously set).
Specific to Oracle. Oracle (as of 9.2) does not support standard jdbc LOB
functionality.
oracleSaveClob
private void oracleSaveClob(java.lang.String fieldName, java.io.Reader data, int length) throws com.jcorporate.expresso.core.dataobjects.DataException
- Saves a Reader into the database given the criteria and the fieldname
Specific to Oracle. Oracle (as of 9.2) does not support standard jdbc LOB
functionality.
(Criteria should have been previously set).
oraclePrepUpdateEmptyLob
private void oraclePrepUpdateEmptyLob(JDBCDataObject baseObject, java.lang.String fieldName, com.jcorporate.expresso.core.db.DBConnection theConnection) throws com.jcorporate.expresso.core.dataobjects.DataException
- Internal helper function to prepare a LOB update for Oracle.
Updates the record, setting the BLOB to to empty_blob() or CLOB to empty_clob() because inserts without
setting the LOB will result in a LOB Locator not being present, which will prevent
the LOB from being added to the record.
- Since:
- $DatabaseSchema $Date: 2004/11/18 02:03:27 $
oraclePrepUpdateNullClob
private void oraclePrepUpdateNullClob(JDBCDataObject baseObject, java.lang.String fieldName, com.jcorporate.expresso.core.db.DBConnection theConnection) throws com.jcorporate.expresso.core.dataobjects.DataException
- 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.
- Since:
- $DatabaseSchema $Date: 2004/11/18 02:03:27 $
oraclePrepSelectForUpdate
protected void oraclePrepSelectForUpdate(JDBCDataObject baseObject, java.lang.String fieldName, com.jcorporate.expresso.core.db.DBConnection theConnection) throws com.jcorporate.expresso.core.dataobjects.DataException
- 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.
- Since:
- $DatabaseSchema $Date: 2004/11/18 02:03:27 $
|
|||||||||
| Home >> All >> com >> jcorporate >> expresso >> core >> dataobjects >> [ jdbc overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.jcorporate.expresso.core.dataobjects.jdbc.LobField