I have a big CLOB (more than 32kB) that I want to read to a String, using StringBuilder. How do I do this in the most efficient way? I can not use the \"int length\" constru
If using Mule, below are the steps.
Follow below steps.
Enable streaming in the connector i.e. progressiveStreaming=2
Typecast DB2 returned CLOB to java.sql.Clob (IBM Supports this type cast)
Convert that to character stream (ASCII stream sometimes may not support some special characters). So you may to use getCharacterStream()
That will return a "reader" object which can be converted to "String" using common-io (IOUtils).
So in short, use groovy component and add below code.
clobTest = (java.sql.Clob)payload.field1
bodyText = clobTest.getCharacterStream()
targetString = org.apache.commons.io.IOUtils.toString(bodyText)
payload.PAYLOADHEADERS=targetString return payload
Note: Here I'm assuming "payload.field1" is holding clob data.
That's it!
Regards Naveen