談笑有鴻儒,往來無白丁

          在恰當?shù)臅r間、地點以恰當?shù)姆绞奖磉_給恰當?shù)娜?..  閱讀的時候請注意分類,佛曰我日里面是談笑文章,其他是各個分類的文章,積極的熱情投入到寫博的隊伍中來,支持blogjava做大做強!向dudu站長致敬>> > 我的微博敬請收聽

          CAUSE

          The Oracle oracle.sql.BLOB OutputStream writes the data in chunks. Since autocommit defaults to true, the first chunk is committed. This results in the write operation for the next chunk of the Blob to fail since it appears to be in the next transaction.
          In those conditions, the ORA-22990 exception will occur with any version of Oracle JDBC driver.

          SOLUTION


          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.

          Here is an example:

          PreparedStatement stmt = conn.prepareStatement("INSERT INTO blobTest VALUES (?,?)"); 
          File fd = new File(testFile); 
          fis = new FileInputStream(fd); 
          stmt.setInt(1,1); 
          stmt.setBinaryStream(2,fis,(int)fd.length());



          where blobTest is a table defined as the following:

          SQL> create table blobTest (id number (4), data blob);
          posted on 2015-08-25 13:56 壞男孩 閱讀(1042) 評論(1)  編輯  收藏 所屬分類: ORACLE篇章

          FeedBack:
          # re: While inserting a large BLOB using JDBC, the application fails with:ORA-22990
          2015-08-25 14:03 | 壞男孩
          The following error occurs while inserting empty blob to return blob locators.

          ORA-22990: lob locator cannot span transaction

          DML statements were executed within a for loop to insert an empty BLOB and an attempt to fetch is made followed by commit within the loop.
          SOLUTION

          It is not advisable to use a COMMIT inside a loop. Use commit after the loop ends.
            回復(fù)  更多評論
            
          主站蜘蛛池模板: 保靖县| 潞城市| 修文县| 太保市| 贵州省| 霍林郭勒市| 闵行区| 苗栗市| 如皋市| 神农架林区| 肇东市| 苍山县| 琼结县| 新竹市| 金秀| 崇文区| 镇平县| 崇州市| 许昌县| 固始县| 东乡县| 尚志市| 通辽市| 乌苏市| 永顺县| 明溪县| 深泽县| 内乡县| 保定市| 衡阳县| 广德县| 黔东| 社旗县| 瓮安县| 海伦市| 宝丰县| 西吉县| 兴安盟| 永清县| 克山县| 鄂托克前旗|