You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Julius Stroffek <Ju...@Sun.COM> on 2007/04/13 11:20:22 UTC
The XAConnection could be closed if there is no global transaction
associated
When I execute the following piece of code (using trunk)
XAConnection xaConn = createXAConnection(connString, "",
"");
XAResource xaRes = xaConn.getXAResource();
Connection conn = xaConn.getConnection();
xaRes.setTransactionTimeout(3);
Xid xid = createXid(i);
conn.setAutoCommit(false);
xaRes.start(xid, XAResource.TMNOFLAGS);
stm = conn.createStatement();
stm.execute(query);
xaRes.end(xid, XAResource.TMSUCCESS);
xaConn.close();
I go the following exception
java.sql.SQLException: Cannot close a connection while a transaction is
still active.
at
org.apache.derby.client.am.SQLExceptionFactory.getSQLException(Unknown
Source)
at
org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.client.am.Connection.closeResourcesX(Unknown
Source)
at org.apache.derby.client.am.Connection.closeResources(Unknown
Source)
at
org.apache.derby.client.net.NetConnection.closeResources(Unknown Source)
at org.apache.derby.client.ClientPooledConnection.close(Unknown
Source)
at org.apache.derby.client.ClientXAConnection.close(Unknown Source)
at XATranTest.test3(XATranTest.java:61)
at XATranTest.main(XATranTest.java:22)
Caused by: org.apache.derby.client.am.SqlException: Cannot close a
connection while a transaction is still active.
at
org.apache.derby.client.am.Connection.checkForTransactionInProgress(Unknown
Source)
... 7 more
It was possible to close the XAConnection object some time ago also when
there was a transaction associated with the connection - see DERBY-2420.
The above code should be allowed. The JDBC spec says:
/The transaction manager is not required to use the same XAResource
object to
commit/rollback a transaction branch as was used to execute the branch.
If different
XAResource objects are used, however, they must be associated with
XAConnection objects that connect to the same resource manager.//
/And because there is 1:1 relation between XAConnection and XAResource
instances the application may use a different connection later to
commit/rollback the transaction. The discussion about this is present on
DERBY-2220.
Does anybody know in which JIRA the change was made? Or how can I figure
that out using svn command?
Thanks a lot,
Julo
Re: The XAConnection could be closed if there is no global transaction
associated
Posted by Kristian Waagan <Kr...@Sun.COM>.
Knut Anders Hatlen wrote:
> Julius Stroffek <Ju...@Sun.COM> writes:
>
>> Does anybody know in which JIRA the change was made? Or how can I
>> figure that out using svn command?
>
> A combination of "svn blame" and "svn log -r XXX" could help you find
> the JIRA issue. But you need to know which file(s) to run "svn blame"
> on.
No need be negative and place the blame ;)
Use 'svn ann[otate]' or 'svn praise' instead :)
--
Kristian
>
Re: The XAConnection could be closed if there is no global transaction
associated
Posted by Knut Anders Hatlen <Kn...@Sun.COM>.
Julius Stroffek <Ju...@Sun.COM> writes:
> Does anybody know in which JIRA the change was made? Or how can I
> figure that out using svn command?
A combination of "svn blame" and "svn log -r XXX" could help you find
the JIRA issue. But you need to know which file(s) to run "svn blame"
on.
--
Knut Anders