use of javax.transaction.xa.Xid in project spanner-jdbc by olavloite.
the class XATester method prepareDeleteRow.
private Xid prepareDeleteRow(CloudSpannerXAConnection xaConnection) throws SQLException, XAException {
Connection connection = xaConnection.getConnection();
Xid xid = getRandomXid();
xaConnection.start(xid, XAResource.TMNOFLAGS);
String sql = "delete from test where id=1000000";
PreparedStatement statement = connection.prepareStatement(sql);
statement.executeUpdate();
xaConnection.end(xid, XAResource.TMSUCCESS);
xaConnection.prepare(xid);
return xid;
}
use of javax.transaction.xa.Xid in project spanner-jdbc by olavloite.
the class XATester method testXARecover.
private void testXARecover(CloudSpannerXAConnection xaConnection) throws SQLException, XAException {
log.info("Started XA recover transaction test");
testXATransaction(xaConnection, CommitMode.None);
Xid[] xids = xaConnection.recover(XAResource.TMSTARTRSCAN);
Assert.assertEquals(1, xids.length);
xaConnection.commit(xids[0], false);
boolean found = false;
try (ResultSet rs = xaConnection.getConnection().createStatement().executeQuery("select * from test where id=1000000")) {
if (rs.next())
found = true;
}
Assert.assertTrue(found);
log.info("Finished XA recover transaction test");
}
use of javax.transaction.xa.Xid in project spanner-jdbc by olavloite.
the class CloudSpannerXAConnectionTest method testJoinWithDifferentXid.
@Test
public void testJoinWithDifferentXid() throws SQLException, XAException {
thrown.expect(CloudSpannerXAException.class);
thrown.expectMessage(CloudSpannerXAException.INTERLEAVING_NOT_IMPLEMENTED);
CloudSpannerXAConnection subject = createSubject();
Xid xid = getRandomXid();
subject.start(xid, XAResource.TMNOFLAGS);
subject.end(xid, XAResource.TMSUCCESS);
subject.start(getRandomXid(), XAResource.TMJOIN);
}
use of javax.transaction.xa.Xid in project spanner-jdbc by olavloite.
the class CloudSpannerXAConnectionTest method testJoinWhenNotEnded.
@Test
public void testJoinWhenNotEnded() throws SQLException, XAException {
thrown.expect(CloudSpannerXAException.class);
thrown.expectMessage(CloudSpannerXAException.INTERLEAVING_NOT_IMPLEMENTED);
CloudSpannerXAConnection subject = createSubject();
Xid xid = getRandomXid();
subject.start(xid, XAResource.TMJOIN);
}
use of javax.transaction.xa.Xid in project spanner-jdbc by olavloite.
the class CloudSpannerXAConnectionTest method testPrepareWithoutEnd.
@Test
public void testPrepareWithoutEnd() throws SQLException, XAException {
thrown.expect(CloudSpannerXAException.class);
thrown.expectMessage(CloudSpannerXAException.PREPARE_BEFORE_END);
CloudSpannerXAConnection subject = createSubject();
Xid xid = getRandomXid();
subject.start(xid, XAResource.TMNOFLAGS);
subject.prepare(xid);
}
Aggregations