File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Transaction API And BLOB

 
Mattias Malmgren
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to insert a blob into Oracle database as part of a javax.transaction.UserTransaction?

I am not sure I read the manuals right. From:

http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Transaction4.html#63068 "However, the Java EE transaction manager does have one limitation: it does not support nested transactions. In other words, it cannot start a transaction for an instance until the preceding transaction has ended."

And from: http://docs.oracle.com/cd/B10500_01/appdev.920/a96591/adl05adv.htm#98415 "Modifying an internal LOB's value through the LOB locator using DBMS_LOB, OCI, or SQL INSERT or UPDATE statements changes the locator from a read consistent locator to an updated locator. Further, the INSERT or UPDATE statement automatically starts a transaction and locks the row. Once this has occurred, the locator may not be used outside the current transaction to modify the LOB value. In other words, LOB locators that are used to write data cannot span transactions"

Is my conclusion right that XA (JTA UserTransaction) can not involve insert of a BLOB? When I try to test my program code I get the ORA-error: ORA-22990
 
Martin Vajsar
Sheriff
Pie
Posts: 3747
62
Chrome Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think the sources you cited support your conclusion. The ORA-22990 simply means that you've ended your transaction too early. Though I don't use XA, I think it leaves it on you when a transaction commits/rolls back. XA just coordinates the transaction among different systems.

I'd suggest to check whether you don't have an autocommit set on your connection. That would produce the ORA-22990 error even if you didn't use distributed transactions. (Amazingly, the autocommit is on by default in JDBC.)
 
Mattias Malmgren
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I thought about autocommit too. Doesn't seam to help though. If I don't use blobOutputStream.flush(); the blob is never saved to the database. The program runs fine if I take the tx.begin(); and tx.commit(); away.



 
Martin Vajsar
Sheriff
Pie
Posts: 3747
62
Chrome Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quick search through Oracle9i Application Developer's Guide - Large Objects (LOBs) does not yield anything about distributed transactions. I don't think it is generally impossible to modify LOBs in distributed environments, but maybe there is some incompatibility in your specific environment. Could you use sql trace to see when the commits happen and align them with commands being run on your application?

Reading the guide mentioned above (in version corresponding to your database) might be useful too. Maybe some scenario involving temporary BLOBs could help you sail through in your environment.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic