-3

this is my blob format

String s=SerialBlob@b23d1da

I was trying to read this blob format with the help of buffer reader, due to which this blob got converted to string format. Is there any way to typecast the current string to blob format

debo
  • 33
  • 1
  • 8
  • `javax.sql.rowset.serial.SerialBlob@b23d1da` is the actual data, or is that what "something" has "sent" in a "request" instead of **actual** data? because converting the string "javax.sql.rowset.serial.SerialBlob@b23d1da" to a blob, will result in a blob with the value of "javax.sql.rowset.serial.SerialBlob@b23d1da" and a mimetype of text/plain – Jaromanda X Jun 25 '17 at 12:12
  • 1
    MB `java` not `javascript`? – Yury Tarabanko Jun 25 '17 at 12:14
  • 1
    `Blob blob = resultSet.getBlob("..."); byte[] bs = blob.getBytes(); String s = new String(bs, StandardCharsets.ISO_8859_1);`. Though I think that is still far from what you want. – Joop Eggen Jun 25 '17 at 12:29
  • String s= javax.sql.rowset.serial.SerialBlob@b23d1da this is my string, getting from url and i want to typecast the above string to blob. – debo Jun 27 '17 at 03:23
  • 1
    @JoopEggen actually my data is coming from webservice which is already in the string format. I m not using the database directly im getting this data from webservices due to this i cannot use Blob blob = resultSet.getBlob("...");..... – debo Jun 27 '17 at 03:26
  • 1
    As the answer mentions, that text is from a toString just showing the Object's hashCode, loosing all content. The web service must serialize the blob, say as Base64. – Joop Eggen Jun 27 '17 at 10:39
  • is it *your* web service? if not, you are out of luck and should report it to them. – Ryan Leach Jun 28 '17 at 02:09

1 Answers1

0

Assuming that your information is correct, you can't solve this issue without modifying your webservice.

javax.sql.rowset.serial.SerialBlob@b23d1da is what a SerialBlob looks like with a naive default Object.toString implementation. It does not contain the information you need to decode / fetch the Blob.

If you are in control of the web service, you will need to modify it to return the Blob in some serializable format, whether that's base64 encoded etc.

Ryan Leach
  • 4,262
  • 5
  • 34
  • 71
  • Thank you for ur valuable reply. Can u suggest me how to retrieve blob data from the web service in java – debo Jun 27 '17 at 03:45
  • @debo I'd advise creating a second question, asking how to serialize and deserialize SerialBlobs correctly from your web service, including the code that currently performs that serialization. Editing your current question would change the question, and you already have negative rep. – Ryan Leach Jun 27 '17 at 03:46
  • Otherwise, try this : https://stackoverflow.com/questions/17400497/how-to-convert-blob-to-string-and-string-to-blob-in-java?rq=1 – Ryan Leach Jun 27 '17 at 03:47
  • in javascript how to send the image string data to (webservices) url, as i was trying to send it gives me the following error message: "data is too long" – debo Jun 27 '17 at 04:02
  • You are better off creating a new question for that. It will get more attention. In addition, if this answer answered *this* question Please upvote and mark as accepted. – Ryan Leach Jun 27 '17 at 05:19
  • "http://www.abcdefgh.com?userid=121&blob=javax.sql.rowset.serial.SerialBlob@b23d1da":..... how can i get this blob data in the next page ............................................................................. @Ryan stack overflow is not allowing me to ask question so only in comments im asking question – debo Jun 27 '17 at 06:29
  • https://meta.stackexchange.com/questions/86997/what-can-i-do-when-getting-we-are-no-longer-accepting-questions-answers-from-th – Ryan Leach Jun 27 '17 at 07:05