public void updateNclob(ConnectionBean1 cb,String id,String content) throws SQLException{
Connection conn=null;
if(cb.con != null){
conn=cb.con;
}else{
conn=cb.getConnection();
}
try {
Statement pstmt = conn.createStatement();
String sql="select bbs_text from tbl_bbs where bbs_no='"+id+"' for update";
ResultSet rs = pstmt.executeQuery(sql);
if(rs.next()){
// CLOB clob = (CLOB) ((DelegatingResultSet)rs).getClob("bbs_text");
CLOB clob = (CLOB) rs.getClob("bbs_text");
OracleClobWriter writer=(OracleClobWriter) clob.getCharacterOutputStream();
BufferedReader in = new BufferedReader(new StringReader (content));
char[] c = new char[1024];
int read=0;
while ((read=in.read(c))!=-1) {
writer.write(c,0,read);
}
writer.flush();
writer.close();
conn.commit();
rs.close();
pstmt.close();
}else{
conn.rollback();
}
}catch(Exception ex){
conn.rollback();
ex.printStackTrace();
}
}
posted on 2009-04-08 09:03
长春语林科技 阅读(173)
评论(0) 编辑 收藏 所属分类:
util