Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

DBMS Lock - COMMIT Problem

693020Jun 10 2011 — edited Oct 15 2014
Hi Folks,

I am trying to do some lock in database without making one or more clients waiting for a DML operation and not having to open some transactions in order to control status changing.
I read some tutorials about DBMS Lock in Oracle but I am facing some problem.

In order to have the lock of my main object, I am doing the following:
1. Open a XA Connection.
2. Call a PROC that generates a UNIQUE HASH and make a LOCK through DBMS_LOCK.REQUEST. In my PROC, I do not have COMMITs and my EJB 3 has REQUIRED as transaction attribute.
3. After calling the PROC, I make my select in my database in order to check if some other request, got the lock.
4. If the select if EMPTY, I call an insert command in the table.

I saw that the DBMS_LOCK ends with the session, but when we close the connection, the session is kept there with the connection in the pool. If other requestor gets the connection from the pool, the DBMS_Lock would be there. In order to handle it, I do a RELEASE_ON_COMMIT when calling the DBMS_LOCK.request.

I could execute it without a XA Connection but it is not my scenario. I have to use a XA Connection.

When using XA, I got the following error, even though I set the RELEASE ON COMMIT for DBMS_LOCK.REQUEST as TRUE or FALSE.
It seems that when calling the DBMS_LOCK, it does a COMMIT anyway.

Caused by: java.sql.SQLSyntaxErrorException: ORA-02089: COMMIT is not allowed in a subordinate session
ORA-06512: at "SYS.DBMS_LOCK", line 250
ORA-06512: at "RSE.GERA_LOCK", line 19

Does anybody could give me a clue, please? :-)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 6 2011
Added on Jun 10 2011
1 comment
654 views