日期:2014-05-16  浏览次数:20345 次

jsp里更新Clob类型字段数据

ResultSet rs = null;
Connection conn = new dbconn().getconnect();
Statement stmt = null;
int news=0;
              conn.setAutoCommit(false);
     stmt = conn.createStatement();
sql="update wx_active_t t set t.wx_plan_id="+plan_name+",t.active_code='"+active_code+"',t.active_content=empty_clob()  where t.id="+active_id;
    
     news= stmt.executeUpdate(sql);

  String sqlt="select active_content from wx_active_t  where id="+active_id+" for update ";

  rs = stmt.executeQuery(sqlt);
  if(rs.next())
  {
System.out.println(javautil.gb2iso(sContent));
oracle.sql.CLOB clob= (oracle.sql.CLOB)rs.getClob("active_content");
outStream = clob.getCharacterOutputStream();
char[] c = javautil.gb2iso(sContent).toCharArray();
outStream.write(c,0,c.length);
outStream.flush();
outStream.close();
conn.commit();
conn.close();
}