//把String类型转换成clob,用于存储
public static CLOB getCLOB(String clobData, Connection
conn){
CLOB tempClob = null;
try {
tempClob =
CLOB.createTemporary(conn,
false,oracle.sql.CLOB.DURATION_SESSION);
tempClob.open(CLOB.MODE_READWRITE);
Writer
tempClobWriter = tempClob.getCharacterOutputStream();
tempClobWriter.write(clobData);
tempClobWriter.flush();
tempClobWriter.close();
tempClob.close();
} catch (Exception exp) {
exp.printStackTrace();
}
return tempClob;
}
//把clob转换成String用于查询
public
static 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) {//
执行循环将字符串全部取出付值给StringBuffer由StringBuffer转成STRING
sb.append(s);
s =
br.readLine();
}
reString = sb.toString();
return reString;
}