2

I am converting a document to byte array, After that, Converting that byte array to oracle BLOB object. But when I am converting I am getting error.

code -

ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
PdfWriter.getInstance(document, byteArrayOutputStream);
byte[] pdfBytes = byteArrayOutputStream.toByteArray();
BLOB blob = new javax.sql.rowset.serial.SerialBlob(pdfBytes);

Error -

 cannot convert from `SerialBlob` to BLOB
Razib
  • 10,965
  • 11
  • 53
  • 80
ketan sharma
  • 103
  • 1
  • 4
  • 11

1 Answers1

1

You're mixing Oracle and Java 7 JDBC types here. BLOB is something which Oracle invented and which doesn't fit really well into the rest of the JDBC design which is one reason why you can't cast the two.

Either use java.sql.Blob or only use Oracle's types (i.e. replace SerialBlob with oracle.sql.BLOB plus the necessary streams).

Related:

Community
  • 1
  • 1
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820