How about the following solution: since the only use of getBlob in
DatabaseReader is to store a private Blob instance variable, and in one
place (in generate) call its getBinaryStream() method, I've modified
DatabaseReader to keep InputStream as its instance variable and use the
result set's getBinaryStream(int column) one method earlier.

- Geoff

The diff: (i'm sending it to bugzilla as part of a patch adding a mod-db
sample doing
file upload -> blob)

Index: blocks/databases/java/org/apache/cocoon/reading/DatabaseReader.java
===================================================================
RCS file:
/home/cvspublic/xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/read
ing/DatabaseReader.java,v
retrieving revision 1.2
diff -u -r1.2 DatabaseReader.java
--- blocks/databases/java/org/apache/cocoon/reading/DatabaseReader.java 7
Jan 2003 23:56:09 -0000 1.2
+++ blocks/databases/java/org/apache/cocoon/reading/DatabaseReader.java 24
Jan 2003 04:35:10 -0000
@@ -53,7 +53,6 @@
 import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.sql.Blob;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -100,7 +99,7 @@
     private ComponentSelector dbselector;
     private String dsn;
     private long lastModified = System.currentTimeMillis();
-    private Blob resource = null;
+    private InputStream resource = null; // because HSQL doesn't yet
implement getBlob()
     private Connection con = null;
     private DataSourceComponent datasource = null;
     private boolean doCommit = false;
@@ -149,7 +148,7 @@
             Request request = ObjectModelHelper.getRequest(objectModel);

             if (this.modifiedSince(set, request, response)) {
-                this.resource = set.getBlob(1);
+                this.resource = set.getBinaryStream(1);

                 if (this.resource == null) {
                     throw new ResourceNotFoundException("There is no
resource with that key");
@@ -299,7 +298,7 @@
             throw new SQLException("The Blob is empty!");
         }

-        InputStream is = new
BufferedInputStream(this.resource.getBinaryStream());
+        InputStream is = new BufferedInputStream(this.resource);

         long expires = parameters.getParameterAsInteger("expires", -1);


> -----Original Message-----
> From: Geoff Howard [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 23, 2003 5:21 PM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: RE: database reader and hsql
>
>
> aargh - I was afraid of that. from the hsql docs:
>
> getBlob
> public java.sql.Blob getBlob(int i)
>                       throws java.sql.SQLException
>
> Up to and including 1.7.1, HSQLDB does not support this feature.
> Calling this method always throws a SQLException, stating that
> the function
> is not supported
>
> it does support
>
> public java.io.InputStream getBinaryStream(int columnIndex) though.
>
> > -----Original Message-----
> > From: Geoff Howard [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, January 23, 2003 4:25 PM
> > To: [EMAIL PROTECTED]
> > Subject: database reader and hsql
> >
> >
> > I've been working with Chris Haul to set up a sample of using the mod-db
> > actions and file uploads together to populate blobs in a
> > database.  It works
> > (after a few simple patches to FilePart and friends).  Very cool.
> >
> > However, to complete the sample I'm now trying to use the new (and very
> > cool) database reader to get uploaded images back out of the
> database, and
> > am having trouble.
> >
> > I get function not supported on getBlob() from hsql result set:
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to