JDBC and BLOBS is not massively documented
... well, its mentioned a lot but I couldn't find a HOWTO, except for one which created a stream and read from it, but I was sure it had to be easier than that!
What has this to do with jetspeed? Well, if you store user's profiles in the DB instead of using files, you will see that the XML is stored in the DB as blobs!
something like this might help get you started by retrieving a blob from the DB as a String.
{{{ String result;
- Blob someBlob;
StringBuffer sqlStmt = new StringBuffer; Statement stmt = conn.createStatement(); sqlStmt.append("select someblob from mytable where ").append(conditional); ResultSet rst = stmt.executeQuery(sqlStmt.toString()); if (rst.next()) {
- someBlob = rst.getBlob(i + 1); byte[] data = someBlob.getBytes(1L, (int) someBlob.length()); String charSet = "ISO-8859-1"; // modify to suit result = new String(data, charSet);
- } }}}
Note that I am assuming MySql; Oracle has its own blob libraries.