OrdImage LoadFromFile异常

问题描述 投票:1回答:1

我正在尝试将图像加载到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");
java oracle jdbc multimedia
1个回答
0
投票

尝试此setAutoCommit(false)

发出setAutoCommit(false)命令。然后,明确提交

所有Blob块都已写入行后的事务和

stream.close()方法已执行。

如果使用Oracle 10g JDBC驱动程序(或更高版本),解决方案

包括使用标准的JDBC api(setBinaryStream方法)>

java.sql.PreparedStatement接口的。在这种情况下,AutoCommit可以

设为true;

© www.soinside.com 2019 - 2024. All rights reserved.