第一种:常用,
Clob clob = rs.getClob("log_detail");//java.sql.Clob
String p_text= "";
if(clob != null){
detailinfo = clob.getSubString((long)1,(int)clob.length());
}
第二种:
Clob clob = rs.getClob("log_detail");//java.sql.Clob
int i = 0;
if(clob != null){
InputStream input = clob.getAsciiStream();
int len = (int)clob.length();
byte by[] = new byte[len];
while(-1 != (i = input.read(by, 0, by.length))){
input.read(by, 0, i);
}
detailinfo = new String(by, "utf-8");
}
第三种:
String Sql="SELECT a.log_detail FROM MONITOR_B.T_SCHEDULER_JOB_LOG A WHERE A.ID=‘123456’;
ResultSet rs=MySql.HB_executeQuery(Sql);
long BlobLength; // BLOB字段长度
byte[] bytes; // BLOB临时存储字节数组
while(rs.next()){
String p_text = ""; // 返回字符串
Clob b=rs.getClob("log_detail");
Reader is =b.getCharacterStream();
BufferedReader br = new BufferedReader(is);
String s = br.readLine();
StringBuffer sb = new StringBuffer();
while (s != null) {// 执行循环将字符串全部取出付值给 StringBuffer由StringBuffer转成STRING
sb.append(s+"\n");
s = br.readLine();
}
p_text=sb.toString();
}