Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle ORA-02089 with Java

I'm getting the following error when trying to call a PL/SQL stored procedure from Java: ORA-02089: COMMIT is not allowed in a subordinate session

It tests fine from Oracle. Does anyone have any experience with this?

like image 250
Greg Avatar asked Aug 13 '12 14:08

Greg


2 Answers

Try this ways;

  • Change the data source to use Non-XA (and check the “Supports Global Transactions” & “Emulate Two-Phase Commit” buttons)
  • Delete the COMMIT from your code.
  • Use the “PRAGMA AUTONOMOUS_TRANSACTION“. This will kind of create a separate transaction that will allow to use a commit.For example:CREATE PROCEDURE XXX AS PRAGMA AUTONOMOUS_TRANSACTION; BEGIN …
like image 126
Sai Ye Yan Naing Aye Avatar answered Oct 13 '22 00:10

Sai Ye Yan Naing Aye


What does the oracle documentation say about the error:

COMMIT was issued in a session that is not the two-phase commit global coordinator.

Basically you are executing a distributed transaction. As part of a distributed transaction you are trying to invoke an autonomous transaction. This is not possible as distributed transactions are required to do a 2PC.

like image 21
steve Avatar answered Oct 12 '22 23:10

steve