Hi,
I've had to use the patch below for my application to work.
The use case is the following: from a JdbcDataSource I'm getting a
JdbcXAConnection (XAConnection/XAResource), and I use the XAConnection
sometimes with a transaction in XA mode (XAResource start/end/commit),
sometimes directly without a transaction.
In XA mode it behaves correctly, but when used in non-tx mode after
it's been used in in XA, then my application fails.
This is because the physical connection is never reset to
autocommit=true when it's done being used after the commit, and that's
a problem.
Note that I cannot call setAutoCommit directly on it, as all the
connection fetching is done through a JCA pool (geronimo-connector).
So this patches fixes it for me. It's for 1.1.114 but the code hasn't
changed since.
Note that Session.begin sets autoCommitAtTransactionEnd=true which in
turn means that Session.commit/rollback will reset to autoCommit=true
at the end, but Session.begin() is never called when using just
JdbcXAConnection.start... Maybe that's the bug.
Florent
--- a/h2/src/main/org/h2/jdbcx/JdbcXAConnection.java
+++ b/h2/src/main/org/h2/jdbcx/JdbcXAConnection.java
@@ -360,19 +360,20 @@
public void commit(Xid xid, boolean onePhase) throws XAException {
if (isDebugEnabled()) {
debugCode("commit("+quoteXid(xid)+", "+onePhase+");");
}
Statement stat = null;
try {
if (onePhase) {
physicalConn.commit();
} else {
stat = physicalConn.createStatement();
stat.execute("COMMIT TRANSACTION TX_" + currentTransactionId);
}
+ physicalConn.setAutoCommit(true);
} catch (SQLException e) {
throw convertException(e);
} finally {
JdbcUtils.closeSilently(stat);
}
currentTransaction = null;
}
--
Florent Guillaume, Director of R&D, Nuxeo
Open Source, Java EE based, Enterprise Content Management (ECM)
http://www.nuxeo.com http://www.nuxeo.org +33 1 40 33 79 87
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.