oracle.sql.CLOB 转 String

最近在用oracle数据库,有个oracle.sql.CLOB转String的需求。
方法如下,也给自己备忘。
	public String clobToString(CLOB clob) {
		String reString = null;
		try {
			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();
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return reString;
	}

你可能感兴趣的:(oracle)