Java clob Field Processing

Source: Internet
Author: User

// Convert clob to string

If (OB [3] instanceof org. hibernate. lob. serializableclob) {// clob Processing

Clob = (clob) ob [3]; // obtain the value of clob
String clobstring = clob. getsubstring (1, (INT) clob. Length (); // converts a value of the clob type to a value of the string type.
S. setsubcontent (clobstring = NULL? "": Clobstring );

}

// Convert clob to string

Public static string getclobtostring (Java. SQL. clob ){
String strval = "";
Try {
If (clob = NULL)
Return "";
Bufferedreader in = new bufferedreader (clob. getcharacterstream ());
Char [] BB = new char [(INT) clob. Length ()];

Int I = 0;
Int itotal = 0;
For (; itotal <clob. Length (); itotal = I + itotal ){

I = in. Read (BB, itotal, (INT) (clob. Length ()-itotal ));
}
Strval = "";
For (Int J = 0; j <BB. length; j ++ ){
Character c = new character (BB [J]);
Strval = strval + C. tostring ();
}
} Catch (exception e ){
E. printstacktrace ();
}
Return strval. Trim ();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.