Hi! can anyone please suggest how to resolve the following issue.
I have a file that is saved as BLOB in oracle database. I am reading that into a "Blob" variable. After this I need to convert the blob into string.
I need to call a servlet that only is expecting a "String" as input.
Can anyone please suggest. If you have a sample code that will be helpful.
Regards Anoop
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35220
7
posted
0
I'm not sure how a servlet can be expecting a String as input type for binary data (which is what you're trying to send). Maybe you can provide some more detail on this.
One way of converting binary data into a string representation is to encode with something like base-64, the output of which will consist entirely of US-ASCII characters. Of course, the receiving end (servlet) needs to be prepared to accept base64-encoded data.
The Jakarta Commons Codec library has a base-64 implementation.
My objective is to call a servlet by passing an xml file. The servlet currently takes the input xml file and returns output as xml. I will need to take this xml parse and store it into oracle table.
I have an xml file that is stored as a blob in oracle. I am reading that blob. Since servlet that is coded is not capable of dealing with blob, I need to convert it into a character stream and send it.
I am having difficulty trying to do that. Please adivise.
Regards Anoop
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35220
7
posted
0
If it's an actual java.sql.Blob, then you can use its getBytes method to retrieve a byte[], which you can then re-format to your hearts content.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: converting Blob to a String for calling POST