use of nl.topicus.jdbc.ICloudSpannerConnection in project spanner-jdbc by olavloite.
the class CloudSpannerXAConnectionTest method testStart.
@Test
public void testStart() throws SQLException, XAException {
CloudSpannerXAConnection subject = createSubject();
ICloudSpannerConnection connection = subject.getConnection();
assertTrue(connection.getAutoCommit());
Xid xid = createXid();
subject.start(xid, XAResource.TMNOFLAGS);
assertNotNull(connection);
assertFalse(connection.getAutoCommit());
thrown.expect(CloudSpannerSQLException.class);
connection.commit();
}
use of nl.topicus.jdbc.ICloudSpannerConnection in project spanner-jdbc by olavloite.
the class CloudSpannerXAConnectionTest method testGetConnection.
@Test
public void testGetConnection() throws SQLException {
CloudSpannerXAConnection subject = createSubject();
ICloudSpannerConnection connection = subject.getConnection();
assertNotNull(connection);
assertTrue(connection.getAutoCommit());
assertEquals(subject.getXAResource(), subject);
connection.setAutoCommit(false);
assertFalse(connection.getAutoCommit());
}
use of nl.topicus.jdbc.ICloudSpannerConnection in project spanner-jdbc by olavloite.
the class CloudSpannerXAConnection method getConnection.
/**
**
* XAConnection interface
***
*/
@Override
public ICloudSpannerConnection getConnection() throws SQLException {
if (logger.logDebug()) {
debug("CloudSpannerXAConnection.getConnection called");
}
Connection connection = super.getConnection();
// false.
if (state == STATE_IDLE) {
connection.setAutoCommit(true);
}
/*
* Wrap the connection in a proxy to forbid application from fiddling
* with transaction state directly during an XA transaction
*/
ConnectionHandler handler = new ConnectionHandler(connection);
return (ICloudSpannerConnection) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { Connection.class, ICloudSpannerConnection.class }, handler);
}
Aggregations