Oracle存Clob字段

//第一步
sql = "insert into BBS_DETAIL(AnnounceID,Body) values (4,EMPTY_CLOB() );";
conn.setAutoCommit(false);
                stmt = conn.createStatement();
                stmt.executeUpdate(sqlstr);
//第二步
String sqll = "select Body from BBS_DETAIL where AnnounceID = 4   for update";
ResultSet rss=stmt.executeQuery(sqll);
                CLOB clob =null;
                if(rss.next()){
             	   clob= ((OracleResultSet)rss).getCLOB(1);
               }
        		clob.putString(1, clobValue);
        	//第三步	
        		///保存clob字段 Bruce.Ran////
        		 String csql="update BBS_DETAIL set Body =? where AnnounceID = 4 ";
        	
                 PreparedStatement pstmt=conn.prepareStatement(csql);
                 pstmt.setClob(1,clob);
                 pstmt.executeUpdate();
                 conn.commit();
                 stmt.close();
                 pstmt.close();

你可能感兴趣的:(oracle,sql,bbs)