OrdImage LoadFromFile 异常

OrdImage LoadFromFile exception

我正在尝试将图像加载到 Oracle 多媒体数据库中。我对 OrdImage.loadDataFromFile() 方法有问题,它抛出一个 SQLException

java.sql.SQLException: ORA-22990: LOB locators cannot span transactions
ORA-06512: at "SYS.DBMS_LOB", line 1127
ORA-06512: at "ORDSYS.ORDSOURCE", line 801
ORA-06512: at "ORDSYS.ORDIMAGE", line 669
ORA-06512: at line 1

我使用的代码:

public void uploadImage(String filename) throws SQLException, IOException
    {
        ...

        // retrieve the previously created ORDImage object for future updating
        Statement stmt2 = dbModel.getConnection().createStatement();
        String selSQL = "select IMAGE from PHOTO where id="+test_id+" for update";
        OracleResultSet rset = (OracleResultSet) stmt2.executeQuery(selSQL);
        rset.next();
        OrdImage imgProxy = (OrdImage)
                rset.getORAData("IMAGE", OrdImage.getORADataFactory());
        rset.close();
        stmt2.close();

        // load the media data from a file to the ORDImage Java object
        try {
            imgProxy.loadDataFromFile("/home/anton/Documents/1.MIT_zima/UPA/upa-project/app/Kataster/car42.gif");
        }
       catch (SQLException ex) {
            System.err.println(ex);
       }
        // set the properties of the Oracle Mm object from the Java object
        imgProxy.setProperties();

        ...
    }

行抛出异常:

imgProxy.loadDataFromFile("/home/anton/Documents/1.MIT_zima/UPA/upa-project/app/Kataster/car42.gif");

试试这个 setAutoCommit(false)

Issue the setAutoCommit(false) command. Then, explicitly commit the

transaction after all of the Blob chunks have been written to the row and

the stream.close() method has been executed.

If using the Oracle 10g JDBC driver (or greater version), a second solution

consists of using the standard JDBC api (setBinaryStream method

of java.sql.PreparedStatement interface). And in this case, AutoCommit can

be set to true;