• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using a BLOB

 
Paulo Silveira
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok
I have a blob field in MySQL
and I can use blob.getBinaryStream() to get a inputStream
but know I want to get a string from it
how do I do that?
could I just use getString instead of getBlob?
 
Michael Zalewski
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should probably use a Clob
http: //java.sun.com/products/jdk/1.2/docs/api/java/sql/Clob.html#getSubString(long, int)
if the data contains a String. Use Clob.getSubString( long pos, int length), such as like this:

If the data must be a Blob, and if it contains Unicode data, you can do like this:

If the Blob is not a Unicode string, you will have to experiment with the http: //java.sun.com/products/jdk/1.2/docs/api/java/lang/String.html#String(byte[], int, int, java.lang.String) constructor that takes a character encoding ID.
BTW: Anyone know how to get URLs like this to post? It didn't work using the URL button. Told me I had a parenthesis in an HTML tag. So I took the [ URL ] tags out, and put a space between http: and the rest of the URL.
[ June 10, 2002: Message edited by: Michael Zalewski ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic