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"));