复制代码 代码如下:
INSERT INTO T_TOPIC(TOPIC_ID,TOPIC_CONTENT) VALUES(‘0000001',empty_clob());
复制代码 代码如下:
ResultSet rs = pstm.executeQuery();
if(rs.next()){
oracle.sql.CLOB lob =(CLOB)rs.getClob(1);
try {
Writer os = lob.getCharacterOutputStream();
os.write(dr.getField("FLD_CONTENT").asString());
os.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
复制代码 代码如下:
CLOB clob = (CLOB)rs.getClob("FLD_CONTENT");
Reader reader = clob.getCharacterStream();
StringBuffer sb=new StringBuffer();
char[] cb = new char[1024];
try {
for(int len = reader.read(cb);len>0;len= reader.read(cb)){
sb.append(cb,0,len);
}
} catch (IOException e) {
throw new SQLException("读取文章内容失败.",e);
}
复制代码 代码如下:
//String sqlsel2 = "select jsonbody from db_ps_listcatalog where" +
// " listtype ='sh11' for update";
// String col="jsonbody";
public boolean updateClob(String sql,String col,String buf){
boolean flag=false;
Statement stem=null;
Connection conn=null;
ResultSet rs=null;
Writer wr = null;
try{
conn= dp.getConnection();
conn.setAutoCommit(false);
stem=conn.createStatement();
rs = stem.executeQuery(sql);
if (rs.next()) {
CLOB clob = (CLOB) rs.getClob(col);
java.lang.reflect.Method methodToInvoke = clob.getClass().getMethod(
"getCharacterOutputStream", (Class[]) null);
wr = (Writer) methodToInvoke.invoke(clob, (Object[]) null);
BufferedWriter bw = new BufferedWriter(wr);
bw.write(buf);
bw.flush();
bw.close();
conn.commit();
conn.close();
}
flag=true;
} catch (Exception ex){
try {
conn.rollback();
} catch (SQLException e) {
e.printStackTrace();
}
}
return flag;
}
新闻热点
疑难解答