Hi all, Does anyone in this forum know how to convert "java.sql.Blob" object to "java.sql.Clob" object? The table field is BLOB and we could not negotiate with DBA to change it to CLOB, but we do want to convert it to CLOB. I initially tried converting the BLOB to bytes array and then bytes array to string, but this works only BLOB is actually readable string. Does anyone know a standard way to convert the java.sql.Blob object to its Clob equivalent in a systematic way?
Well, binary data really isn't character data, so storing it as such is going to be a bit of a hack. An easy way to convert binary data into character data would be to base-64 encode it (the Apache Commons Codec library can do this). Not only will that give you characters, but those characters will exclusively be ASCII, so there's never a problem with having to deal with Unicode or other encodings.
Originally posted by Padmanabhan Venkitasubramanian: The table field is BLOB and we could not negotiate with DBA to change it to CLOB,
Why does the DBA not want it to a CLOB? Addressing this may be more beneficial than coming up with a hack. And it's easier to change the type now (or add a column or some logical workaround) rather than later.