Convert String to Blob
String data = "hello world";
java.sql.Blob blob = org.hibernate.Hibernate.createBlob(data.getBytes());
Convert Blob to String
byte[] bdata = blob.getBytes(1, (int)blob.length());
String data1 = new String(bdata);
Subscribe to:
Post Comments (Atom)
2 comments:
What if the length of blob exceeds the maxvalue for the int? Considering blob is for binary, that is possible.
BLOB may exceeds the max value for int.
If the data is too large then u can use CLOB format.
if you want to store large data, use a CLOB and to store an image, use a BLOB data types.
Post a Comment