//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;
}
分享到:
2012-11-19 11:12
浏览 4612
分类:数据库
评论