In the first two days of the project, there is a field of type CLOB, which cannot be directly converted to a string type when fetching data with pure SQL. So you have to manually turn, and then use the following code, posted here to share, if the small partners need to directly take to use, this pro-test is can be used oh ...
Not much to say, the code is the kingly ...
Clob type to string public string clobtostring (Clob Clob) throws SQLException, IOException { String restring = "";
reader is = Clob.getcharacterstream ();//Get stream bufferedreader br = new BufferedReader (is); String s = br.readline (); StringBuffer sb = new StringBuffer (); while (s! = null) {///execution loop takes all strings out of the value to StringBuffer from StringBuffer to string sb.append (s); s = Br.readline (); } restring = Sb.tostring (); if (br!=null) { br.close (); } if (is!=null) { is.close (); } return restring; }
is not very simple wow, small friends to try it ...
Java CLOB type to String type