Converting BLOB to string

Hi,

I need to convert BLOB data to a string. There is this BLOB data which is a combination of string and media files. I know we won’t be able to see media data as string. But at least I need to see the text part in the BLOB data. I have this java code to convert BLOB to a byte array and then I am using “bytesToString” service. But its not giving me the output as required. Output is displayed like 0 | 0 | |E || .

IDataCursor idc = pipeline.getCursor();
idc.first(“blob”);
oracle.sql.BLOB blobObj = (oracle.sql.BLOB)idc.getValue();
try {
long length = blobObj.length();
byte msg = blobObj.getBytes(1, (int)blobObj.length());
idc.insertAfter(“bytes”, msg);
} catch (Exception e){
}

Any ideas,

Thanks,

Pauly

BLOBs are binaries. To convert it to string you need to understand how it was created (format of the BOLB). For example, first 20 bytes may represent string, next 50 represents java object etc. Then get the first 20 bytes in a byte array and convert it to string.

Hi,

Thanks for the prompt response. This data is inserted into database by JDE BF. You will not know how how many bytes represent string etc.

Thanks,
Pauly

I am afraid that is not possible. What you are trying to do is to write a viewer application with out knowing the file format.

Hi

I have a similar problem, wherein i insert the BLOB data into database using the JDBC adapter and while retrieving the BLOB data from the database, i am facing problems while converting the same to string.

Please let me know ur valuable suggestions.

Thanks
Rakesh

Hi again

I would like to let you know that i am using wM 6.1.

Thanks
Rakesh

Hi

If you are using BLOBs with Oracle, check out Google for Oracle java classes. There are a number of custom built classes to convert between Blobs & Strings. ([url=“http://download-east.oracle.com/otn_hosted_doc/jdeveloper/904preview/jdbc-javadoc/index.html”]http://download-east.oracle.com/otn_hosted_doc/jdeveloper/904preview/jdbc-javadoc/index.html[/url])

As for the other question, why are you combining String & BLOB data in a BLOB?? Can you influence the way the data is stored?

Chris

Hi

Thanks for ur response.

I am not combining string and BLOB data in a BLOB, i am just trying to convert the BLOB data into string using the JDBC adapter.

Thanks
Rakesh