Hi list,
here is a small patch which adds functionality to display a blob field from the database. It currently works only for a "new" blob handling mode.
As I wrote earier, it would be good to receive some hints about blob handling strategy in order to make DbTextAreaForBlobs work.
regards, Dziugas Baltrunas
Index: DbBlobContentTag.java
===================================================================
RCS file: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbBlobContentTag.java,v
retrieving revision 1.13
diff -u -r1.13 DbBlobContentTag.java
--- DbBlobContentTag.java 12 May 2004 16:14:48 -0000 1.13
+++ DbBlobContentTag.java 16 Jul 2004 12:03:57 -0000
@@ -28,6 +28,7 @@
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.sql.SQLException;
+import java.sql.Blob;
import org.dbforms.config.FieldTypes;
import org.dbforms.util.SqlUtil;
@@ -123,7 +124,18 @@
logCat.info("fs- file not found");
}
} else {
- throw new IllegalArgumentException("DbBlobContentTag is currently
only for DISKBLOBS - feel free to copy code from FileServlet.java to this place to
bring this limitation to an end :=)");
+ try {
+ /* TODO: we obviously need a classic mode blob handling here as
well */
+ Blob blob = rs.getBlob(1);
+ BufferedReader br =
+ new BufferedReader(new
InputStreamReader(blob.getBinaryStream()));
+ char[] c = new char[1024];
+ int read;
+ while ((read = br.read(c)) != -1)
+ contentBuf.append(c, 0, read);
+ } catch (NullPointerException e) {
+ // the blob field was empty
+ }
}
} else {
logCat.info("fs- we have got no result" + queryBuf);
