1、我的数据库是oracle11g 遇到取出来的字段是clob类型,但是所需要的是string类型,写一个转换函数就可以解决问题了。
// Clob类型 转String
public String ClobToString(Clob clob) throws SQLException, IOException {
String reString = "";
Reader is = clob.getCharacterStream();
BufferedReader br = new BufferedReader(is);
String s = br.readLine();
StringBuffer sb = new StringBuffer();
while (s != null) {
sb.append(s);
s = br.readLine();
}
reString = sb.toString();
if(br!=null){
br.close();
}
if(is!=null){
is.close();
}
return reString;
}
2、调用即可
pubKeyStr = ClobToString((Clob)app.get("pubkey"));
priKeyStr = ClobToString((Clob)app.get("prikey"));