Java Doc for LobField.java in  » J2EE » Expresso » com » jcorporate » expresso » core » dataobjects » jdbc » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » Expresso » com.jcorporate.expresso.core.dataobjects.jdbc 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


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 $


Field Summary
 booleanalreadyInTransaction
    
protected  JDBCDataObjectcriteria
     The dataobject to use to build the SQL search/update statements.
protected  DBConnectionmyConnection
    

Constructor Summary
public  LobField()
     Default constructor.

Method Summary
public  voidclose()
     Close the query resources held by the object.
protected  voidfinalize()
     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  voidfinalizeUpdate(DBConnection theConnection)
    
public  BlobgetBlob(String fieldName)
     Retrieves a java.sql.Blob object given the criteria object set previously.
public  InputStreamgetBlobStream(String fieldName)
     Retrieve an input stream for a binary object stored in the database.
Parameters:
  fieldName - the field name to retrieve.
public  ClobgetClob(String fieldName)
     Retrieves a java.sql.Clob object given the criteria object set previously.
public  InputStreamgetClobAsciiStream(String fieldName)
     Retrieve a java.io.InputStream a.k.a.
public  java.io.ReadergetClobStream(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  StringgetClobString(String fieldName)
     CLOB convenience method.
protected  JDBCDataObjectgetCriteria()
    
protected  voidoraclePrepSelectForUpdate(JDBCDataObject baseObject, String fieldName, DBConnection theConnection)
     Internal helper function to prepare a BLOB update for Oracle.
protected  voidprepSelectResultSet(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  PreparedStatementprepUpdate(JDBCDataObject baseObject, String fieldName, DBConnection theConnection)
    
public  voidsaveBlob(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  voidsaveBlob(String fieldName, Blob data)
     Saves a java.sql.Blob to the record matching the criteria earlier set.
public  voidsaveClob(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  voidsaveClob(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  voidsaveClob(String fieldName, String data)
     Saves a string to a CLOB field.
public  voidsaveClob(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  voidsetCriteria(JDBCDataObject newCriteria)
     Set the search criteria for the blob.

Field Detail
alreadyInTransaction
boolean alreadyInTransaction(Code)



criteria
protected JDBCDataObject criteria(Code)
The dataobject to use to build the SQL search/update statements.



myConnection
protected DBConnection myConnection(Code)




Constructor Detail
LobField
public LobField()(Code)
Default constructor. Currently does nothing.




Method Detail
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.



finalizeUpdate
protected void finalizeUpdate(DBConnection theConnection) throws DataException(Code)



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 error

Modify 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.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.