db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mamta A. Satoor (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-8) Connection object gets created with un-supported holdability on getting Connection object from XAConnection "inside" the global transaction
Date Wed, 01 Dec 2004 23:06:22 GMT
     [ http://nagoya.apache.org/jira/browse/DERBY-8?page=comments#action_56076 ]
     
Mamta A. Satoor commented on DERBY-8:
-------------------------------------

Should we then reconsider what happens to the holdability of the connection handle(got by
calling a getConnection() method on a XAConnection OUTSIDE the global transaction) when it
becomes part of a global transaction? 

Following example code shows that Derby currently (silently) switches the the holdability
of the connection handle from HOLD_CURSORS_OVER_COMMIT to CLOSE_CURSORS_AT_COMMIT when it
becomes part of the global transaction.

    EmbeddedXADataSource dscsx = new EmbeddedXADataSource(); 
    dscsx.setDatabaseName("wombat"); 
    XAConnection xac = dscsx.getXAConnection("fred", "wilma"); 
    XAResource xr = xac.getXAResource(); 
    Xid xid = getXid(27, (byte) 21, (byte) 01); 
    Connection conn1 = xac.getConnection(); 
    System.out.println("By default, autocommit is " + conn1.getAutoCommit() + " for a connection");
    System.out.println("Default holdability for a connection is HOLD_CURSORS_OVER_COMMIT");
    System.out.println("CONNECTION(not in xa transaction yet) HOLDABILITY " + (conn1.getHoldability()
== ResultSet.HOLD_CURSORS_OVER_COMMIT));
    xr.start(xid, XAResource.TMNOFLAGS);
    System.out.println("Notice that autocommit now is " + conn1.getAutoCommit() + " for connection
because it is part of the global transaction");
    System.out.println("Notice that connection's holdability at this point is CLOSE_CURSORS_AT_COMMIT
because it is part of the global transaction");
    System.out.println("CONNECTION(in xa transaction) HOLDABILITY " + (conn1.getHoldability()
== ResultSet.HOLD_CURSORS_OVER_COMMIT));

Output of this code snippet when run under Derby is as follows.
START XA HOLDABILITY TEST
By default, autocommit is true for a connection
Default holdability for a connection is HOLD_CURSORS_OVER_COMMIT
CONNECTION(not in xa transaction yet) HOLDABILITY true
Notice that autocommit now is false for connection because it is part of the global transaction
Notice that connection's holdability at this point is CLOSE_CURSORS_AT_COMMIT because it is
part of the global transaction
CONNECTION(in xa transaction) HOLDABILITY false

thanks,
Mamta

> Connection object gets created with un-supported holdability on getting Connection object
from XAConnection "inside" the global transaction
> -------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: DERBY-8
>          URL: http://nagoya.apache.org/jira/browse/DERBY-8
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Versions: 10.0.2.0
>     Reporter: Tulika Agrawal
>     Priority: Minor

>
> Reporting for Mamta Satoor, filed on Derby-dev list.
> I think there is a bug in Derby when the user code tries to get the
> Connection object from XAConnection "inside" the global transaction.
> In this case, the Connection object gets created with un-supported
> holdability. Look at the following piece of code and it's output to
> see what exactly happens
>     EmbeddedXADataSource dscsx = new EmbeddedXADataSource();
>     dscsx.setDatabaseName("wombat");
>     XAConnection xac = dscsx.getXAConnection("fred", "wilma");
>     XAResource xr = xac.getXAResource();
>     xid = getXid(27, (byte) 21, (byte) 01);
>     xr.start(xid, XAResource.TMNOFLAGS);
>     conn1 = xac.getConnection();
>     System.out.println("This is a bug. Connection's holdability should
> have been CLOSE_CURSORS_AT_COMMIT since it is in the global
> transaction");
>     System.out.println("CONNECTION(in xa transaction) HOLDABILITY " +
> (conn1.getHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT));
>     System.out.println("Autocommit on Connection inside global
> transaction has been set correctly to " + conn1.getAutoCommit());
>     xr.end(xid, XAResource.TMSUCCESS);
> The output for the above piece of code is
>     This is a bug. Connection's holdability should have been
> CLOSE_CURSORS_AT_COMMIT since it is in the global transaction
>     CONNECTION(in xa transaction) HOLDABILITY true
>     Autocommit on Connection inside global transaction has been set
> correctly to false

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


Mime
View raw message