con.setAutoCommit(false);
//一句一句执行sql
DECLARE cont CLOB;
BEGIN
    SELECT content INTO cont FROM clobt WHERE id=1 FOR UPDATE;
    DBMS_LOB.WRITEAPPEND(cont, 5, 'abcde');
END;
////
con.commit();
con.setAutoCommit(true);

解决方案 »

  1.   

    con.setAutoCommit(false);
    //一句一句执行sql
    DECLARE cont CLOB;
    BEGIN
        SELECT content INTO cont FROM clobt WHERE id=1 FOR UPDATE;
        DBMS_LOB.WRITEAPPEND(cont, 5, 'abcde');
    END;
    ////
    con.commit();
    con.setAutoCommit(true);
      

  2.   

    我试用如下方式执行:
    stmt.addBatch("DECLARE cont CLOB;");
    stmt.addBatch("begin select content into cont from clobt where id=2 for update;");
    stmt.addBatch("dbms_lob.writeappend(cont, 5, 'abcde');");
    stmt.addBatch("END;");
    stmt.executeBatch();
    得到如下报错:
    java.sql.BatchUpdateException: error occurred during batching: ORA-06550: line 1, column 18:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:begin function package pragma procedure subtype type use
    <an identifier> <a double-quoted delimited-identifier> cursor form currentat oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:380)
    at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:432)
    at oracle.jdbc.driver.OracleStatement.executeBatch(OracleStatement.java:4651)
    at clobtest.clobMgr.addClob(clobMgr.java:314)
    at clobtest.MainRun.main(MainRun.java:24)