Shawn wrote:
Apologies again,It's also possible to marshall the FileHolder class into an XML stream (that contains also binary data?) and store it into the database.
I knew I didn't really have a handle on the answer and was just trying to move the discussion along.
Luca pointed out a way to get it from the database as a java object.
I suppose other languages could retrieve the xml stream, parse it and retrieve the required data.
example: JSX http://www.csse.monash.edu.au/~bren/JSX/ http://www.csse.monash.edu.au/~bren/JSX/tech.html
I did a simple utility class with marshall / unmarshall methods... in attachment (maybe it could be useful...)
my .02 euro, as well ;^)
Regards, Luca
As for non java applications accessing Blobs retrieved from the database via dbforms, YOU WANT TO KNOW IF THAT IS POSSIBLE.
I don't know of a way. If anyone does, please let me know so I can document it in the UsersGuide.
As for the question of whether time should be invested into making it possible (if it is not now), it is a good question to ask. IS IT NECESSARY FOR PEOPLE TO ACCESS BLOBS FROM NON-JAVA APPLICATIONS?
Does the "build it and somebody will find a use" rule apply?
What happens if a C++/PHP/Perl/TCL/Ruby/.NET/Jelly/XYZ application tries to access this BLOB. It actually DOES NOT contain the binary content I passed but a serialized FileHolder. And non-Java languages might have a problem processing a serialized Java objects
package com.pow2.blablah.util;
import java.io.*; import java.util.*; import org.apache.log4j.Category; import JSX.*; /** * JSX Helper class. * <br> * See <code>http://www.csse.monash.edu.au/~bren/JSX/tech.html</code> * for further informations. * * @author Luca Fossato * @created 15 maggio 2002 */ public class MarshallerUtil { private static Category cat = Category.getInstance(MarshallerUtil.class); /** * Trasform the input XML String into a Java object. * * @param str the String containing the Java object XML description * @return the Java object * @exception Exception if any error occurs */ public static Object unMarshallObject(String str) throws Exception { ByteArrayInputStream bis = null; ObjIn in = null; Object obj = null; try { bis = new ByteArrayInputStream(str.getBytes()); in = new ObjIn(bis); obj = in.readObject(); } finally { if (in != null) in.close(); if (bis != null) bis.close(); } return obj; } /** * Trasform the input object into an XSL String. * * @param obj the object to transform * @return the XML String representation of the input object */ public static String marshallObject(Object obj) throws Exception { StringWriter sw = null; ObjOut out = null; String s = null; try { sw = new StringWriter(); out = new ObjOut(new PrintWriter(new BufferedWriter(sw), true)); out.writeObject(obj); s = sw.toString(); } finally { if (out != null) out.close(); if (sw != null) sw.close(); } return s; } }