Hi Kathey,
 
Just to summarize, the holdability table will look the same for EmbedConnection as well as BrokeredConnection.
 
                        Global Transaction                             Local Transaction
JDK13    CLOSE_CURSORS_AT_COMMIT        conn holdability (Default HOLD_CURSORS_OVER_COMMIT)
JDK14+   CLOSE_CURSORS_AT_COMMIT       conn holdability (Default HOLD_CURSORS_OVER_COMMIT)
 
A Connection object will have it's holdability set to default which is HOLD_CURSORS_OVER_COMMIT. When the connection joins a global transaction, the holdability will get switched internally to CLOSE_CURSORS_AT_COMMIT. When the connection leaves the global transaction and becomes part of local transaction, the holdability is restored to what it was before entering the global transaction. It works this way in both jdk13 and jdk14+. One thing to keep in mind is that PreparedStatement get the holdability from where they are prepared and not where they are executed, for instance,
Start Local Transaction
Connection holdability (default - HOLD_CURSORS_OVER_COMMIT)
PreparedStatement (holdability will be HOLD_CURSORS_OVER_COMMIT)
ResultSet from PreparedStatement will have holdability as HOLD_CURSORS_OVER_COMMIT
Start Global Transaction
Connection holdability switches to CLOSE_CURSORS_AT_COMMIT
Another ResultSet from PreparedStatement will attempt to have the preparedStatement's holdability and that will cause exception because Global transactions do not support holdable cursors.
Exit Global Transaction and become part of Local Transaction
Connection holdability back to HOLD_CURSORS_OVER_COMMIT
 
I have come across one bug with jdk13 though, where the holdability is not getting restored back to HOLD_CURSORS_OVER_COMMIT when the connection becomes part of local transaction after leaving global transaction. I will enter a JIRA entry for it and start working on it.
 
thanks,
Mamta
On 6/12/05, Kathey Marsden <[EMAIL PROTECTED]> wrote:
Mamta Satoor wrote:

>
> Your table of holdability for JDK13 and Local Transaction should have
> "conn holdability (Default HOLD_CURSORS_OVER_COMMIT)". (At least, that
> is what I think. If I am wrong, feel free to bring it up because I
> haven't worked on holdability for quite some time). But with my
> suggested change, the table will look like as follows
>                         Global Transaction
> Local Transaction
> JDK13    CLOSE_CURSORS_AT_COMMIT        conn holdability (Default
> HOLD_CURSORS_OVER_COMMIT)
> JDK14+   CLOSE_CURSORS_AT_COMMIT       conn holdability (Default
> HOLD_CURSORS_OVER_COMMIT)

I should have clarified that this was for a BrokeredConnection  obtained
from XAConnection.    Your example shows a regular EmbedConnection.
Should a BrokeredConnection obtained from an XAConnection default to
HOLD_CURSORS_OVER_COMMIT in a local transaction?

Thanks

Kathey









Reply via email to