0

I have a Java script, that will get the BLOB data from the database and then email this file to a specific email address. My problem is, that I have to use some framework functions (I can make DB calls only through these) and I think it's not handling BLOB datatypes... All I can get is the string representation of the result, this is the log line result of the code (framework call):

String s = String.valueOf(result.get(j).getValue("BLOB_DATA"));
System.out.println(s);

Log result:

<binary data> 50 KB

So this is the data I have to convert SOMEHOW into a valid pdf file, but right now I'm stuck...

Is it even possible to convert it into a valid byte[]? I tried it several ways, but all I get is invalid files... :(

Crazyjavahacking
  • 9,343
  • 2
  • 31
  • 40
VORiAND
  • 145
  • 3
  • 17
  • 35
  • What is `result`? Is it a `List`? What types does it store? – Dragondraikk Jul 03 '15 at 10:11
  • You got me confused by writing "java script" (sound much like javascript). Mind talking about Java program ? – Marged Jul 03 '15 at 10:11
  • Try new String(result.get(j).getValue("BLOB_DATA")); It works in case if byte data. – Adam Voga Jul 03 '15 at 10:12
  • Perhaps a duplicate ? http://stackoverflow.com/questions/8445960/java-reading-blob-from-oracle – Marged Jul 03 '15 at 10:13
  • is result.get(j).getValue("BLOB_DATA") return the data type java.sql.Blob? If yes, please refer to http://stackoverflow.com/questions/6662432/easiest-way-to-convert-a-blob-into-a-byte-array If no, then what is the data type returned by result.get(j).getValue("BLOB_DATA")? – diufanman Jul 03 '15 at 10:20
  • Welll... If I try to CAST the result: Blob s = (Blob)result.get(j).findValue("PDF"); to Java Blob it says "java.lang.ClassCastException: ifs.fnd.ap.Bytedata cannot be cast to java.sql.Blob" – VORiAND Jul 03 '15 at 10:39
  • 1
    ifs.fnd.ap.Bytedata bytedata = (ifs.fnd.ap.Bytedata) result.get(j).findValue("PDF"); then look up the java doc for ifs.fnd.ap.Bytedata to see how to convert this datatype to byte array. – diufanman Jul 03 '15 at 10:46
  • "All I can get is the string representation" which is not the binary data. – Raedwald Jul 03 '15 at 11:33

0 Answers0