Java Code Examples for javax.sql.XAConnection

The following examples show how to use javax.sql.XAConnection. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: FHIR   Source File: FHIRProxyXADataSource.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public XAConnection getXAConnection() throws SQLException {
    log.entering(this.getClass().getName(), "getXAConnection()");
    try {
        XAConnection connection = null;

        // XA recovery will be triggered by a call to this method, while
        // threadlocal contains "default/default" for the tenant-id and datastore-id.
        // If we find something else on thread-local then we'll treat it as an error.
        String tenantId = FHIRRequestContext.get().getTenantId();
        String dsId = FHIRRequestContext.get().getDataStoreId();
        if (FHIRConfiguration.DEFAULT_TENANT_ID.equals(tenantId) && FHIRConfiguration.DEFAULT_DATASTORE_ID.equals(dsId)) {
            log.info("Initiating XA recovery process...");
            connection = new RMXAConnectionResource(this);
        } else {
            throw new SQLException("The getXAConnection() method should be called only during XA recovery.");
        }
        return connection;
    } finally {
        log.exiting(this.getClass().getName(), "getXAConnection()");
    }
}
 
Example 2
/**
 * check whether commit without statement will flow by checking its transaction id
 * on client. This test is run only for client where commits without an
 * active transactions will not flow to the server.
 * DERBY-4653
 *
 * @throws SQLException
 **/
public void testConnectionFlowCommit()
        throws SQLException {
    ConnectionPoolDataSource ds = J2EEDataSource.getConnectionPoolDataSource();

    PooledConnection pc = ds.getPooledConnection();
    Connection conn = pc.getConnection();

    testConnectionFlowCommitWork(conn);
    conn.close();

    //Test for XADataSource
    XADataSource xs = J2EEDataSource.getXADataSource();
    XAConnection xc = xs.getXAConnection();
    conn = xc.getConnection();
    testConnectionFlowCommitWork(conn);
    conn.close();

    //Test for DataSource
    DataSource jds = JDBCDataSource.getDataSource();
    conn = jds.getConnection();
    testConnectionFlowCommitWork(conn);
    conn.close();
}
 
Example 3
@Test
public void shouldGetConnectionAndCommitWithCredentials() throws SQLException {
    String username = "testUsername";
    String password = "testPassword";
    Connection mockConnection = mock(Connection.class);
    XAConnection mockXaConnection = mock(XAConnection.class);
    given(mockXaConnection.getConnection()).willReturn(mockConnection);
    given(this.mockXaDataSource.getXAConnection(username, password)).willReturn(mockXaConnection);

    // TODO properties not used
    Properties properties = new Properties();
    properties.put(TransactionalDriver.XADataSource, this.mockXaDataSource);
    properties.put(TransactionalDriver.userName, username);
    properties.put(TransactionalDriver.password, password);

    Connection connection = this.dataSourceBean.getConnection(username, password);
    assertThat(connection).isInstanceOf(ConnectionImple.class);

    connection.commit();

    verify(this.mockXaDataSource, times(1)).getXAConnection(username, password);
    verify(mockXaConnection, times(1)).getConnection();
    verify(mockConnection, times(1)).commit();
}
 
Example 4
@Test
public void enableWireCompression() throws Exception {
    assumeThat("Test only works with pure java connections", FBTestProperties.GDS_TYPE, isPureJavaType());
    assumeTrue("Test requires wire compression", getDefaultSupportInfo().supportsWireCompression());
    ds.setWireCompression(true);

    XAConnection xaConnection = ds.getXAConnection();
    try (Connection connection = xaConnection.getConnection()){
        assertTrue(connection.isValid(0));
        GDSServerVersion serverVersion =
                connection.unwrap(FirebirdConnection.class).getFbDatabase().getServerVersion();
        assertTrue("expected wire compression in use", serverVersion.isWireCompressionUsed());
    } finally {
        xaConnection.close();
    }
}
 
Example 5
Source Project: gemfirexd-oss   Source File: J2EEDataSourceTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * check whether commit without statement will flow by checking its transaction id
 * on client. This test is run only for client where commits without an
 * active transactions will not flow to the server.
 * DERBY-4653
 * 
 * @throws SQLException
 **/
public void testConnectionFlowCommit()
        throws SQLException {
    ConnectionPoolDataSource ds = J2EEDataSource.getConnectionPoolDataSource();

    PooledConnection pc = ds.getPooledConnection();
    Connection conn = pc.getConnection();

    testConnectionFlowCommitWork(conn, 1);
    conn.close();
    
    //Test for XADataSource
    XADataSource xs = J2EEDataSource.getXADataSource();
    XAConnection xc = xs.getXAConnection();
    conn = xc.getConnection();
    testConnectionFlowCommitWork(conn, 1);
    conn.close();
    
    //Test for DataSource
    DataSource jds = JDBCDataSource.getDataSource();
    conn = jds.getConnection();
    testConnectionFlowCommitWork(conn, 1);
    conn.close();       
}
 
Example 6
/**
 * Test if calling commit throws an exception when participating in a distributed transaction (JDBC 4.0 section 12.4).
 */
@Test
public void testInDistributed_commit() throws Exception {
    XAConnection pc = getXAConnection();
    XAResource xa = pc.getXAResource();
    Xid xid = new XidImpl();
    try (Connection con = pc.getConnection()) {
        con.setAutoCommit(false);
        xa.start(xid, XAResource.TMNOFLAGS);

        expectedException.expect(SQLException.class);
        expectedException.expect(sqlStateEquals(SQLStateConstants.SQL_STATE_INVALID_TX_STATE));

        con.commit();
    } finally {
        xa.end(xid, XAResource.TMSUCCESS);
        xa.rollback(xid);
    }
}
 
Example 7
/**
 * Tests if the connection obtained from the PooledConnection can be used
 * and has expected defaults.
 */
@Test
public void testConnection() throws SQLException {
    XAConnection pc = getXAConnection();

    Connection con = pc.getConnection();

    assertTrue("Autocommit should be true", con.getAutoCommit());
    assertTrue("Read-only should be false", !con.isReadOnly());
    assertEquals("Tx isolation level should be read committed.",
            Connection.TRANSACTION_READ_COMMITTED, con.getTransactionIsolation());

    try (Statement stmt = con.createStatement()) {
        ResultSet rs = stmt.executeQuery("SELECT cast(1 AS INTEGER) FROM rdb$database");

        assertTrue("Should select one row", rs.next());
        assertEquals("Selected value should be 1.", 1, rs.getInt(1));
    }
    con.close();
    assertTrue("Connection should report as being closed.", con.isClosed());
}
 
Example 8
Source Project: gemfirexd-oss   Source File: J2EEDataSourceTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Test that connections retrieved from {@code XADataSource} that are part
 * of a global XA transaction, behave as expected when {@code close()} is
 * called and the transaction is active.
 */
public void testCloseActiveConnection_XA_global()
    throws SQLException, XAException
{
    XADataSource ds = J2EEDataSource.getXADataSource();
    XAConnection xa = ds.getXAConnection();
    XAResource xar = xa.getXAResource();
    Xid xid = new cdsXid(1, (byte) 2, (byte) 3);
    xar.start(xid, XAResource.TMNOFLAGS);
    // auto-commit is always off in XA transactions, so we expect
    // getAutoCommit() to return false without having set it explicitly
    testCloseActiveConnection(xa.getConnection(), false, true);
    Connection c = xa.getConnection();
    c.setAutoCommit(false);
    testCloseActiveConnection(c, false, true);
    xar.end(xid, XAResource.TMSUCCESS);
}
 
Example 9
/**
 * DERBY-4232: Test that an XA transaction can be suspended and resumed
 * when a timeout is in effect.
 */
public void testTransactionTimeoutAndSuspendResume() throws Exception {
    XADataSource xads = J2EEDataSource.getXADataSource();
    XAConnection xac = xads.getXAConnection();
    XAResource xar = xac.getXAResource();
    Xid xid = XATestUtil.getXid(1, 2, 3);

    // Start work in a new transaction with a timeout
    xar.setTransactionTimeout(500);
    xar.start(xid, XAResource.TMNOFLAGS);

    // Suspend the transaction
    xar.end(xid, XAResource.TMSUSPEND);

    // Resume the transaction (used to fail with a XAER_PROTO on the
    // network client)
    xar.start(xid, XAResource.TMRESUME);

    // End the transaction and free up the resources
    xar.end(xid, XAResource.TMSUCCESS);
    xar.rollback(xid);
    xac.close();
}
 
Example 10
Source Project: Tomcat8-Source-Read   Source File: ProxyConnection.java    License: MIT License 5 votes vote down vote up
public boolean isWrapperFor(Class<?> iface) {
    if (iface == XAConnection.class && connection.getXAConnection()!=null) {
        return true;
    } else {
        return (iface.isInstance(connection.getConnection()));
    }
}
 
Example 11
Source Project: tomcatsrc   Source File: ProxyConnection.java    License: Apache License 2.0 5 votes vote down vote up
public Object unwrap(Class<?> iface) throws SQLException {
    if (iface == PooledConnection.class) {
        return connection;
    }else if (iface == XAConnection.class) {
        return connection.getXAConnection();
    } else if (isWrapperFor(iface)) {
        return connection.getConnection();
    } else {
        throw new SQLException("Not a wrapper of "+iface.getName());
    }
}
 
Example 12
Source Project: FHIR   Source File: RMXAConnectionResource.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void addConnectionEventListener(ConnectionEventListener listener) {
    log.entering(this.getClass().getName(), "addConnectionEventListener");
    try {
        // Drive the method calls to each of the proxied XAConnections.
        List<XAConnection> connections = getProxiedXAConnections();
        for (XAConnection connection : connections) {
            connection.addConnectionEventListener(listener);
        }
    } finally {
        log.exiting(this.getClass().getName(), "addConnectionEventListener");
    }
}
 
Example 13
Source Project: FHIR   Source File: RMXAConnectionResource.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void removeStatementEventListener(StatementEventListener listener) {
    log.entering(this.getClass().getName(), "removeStatementEventListener");
    try {
        // Drive the method calls to each of the proxied XAConnections.
        List<XAConnection> connections = getProxiedXAConnections();
        for (XAConnection connection : connections) {
            connection.removeStatementEventListener(listener);
        }
    } finally {
        log.exiting(this.getClass().getName(), "removeStatementEventListener");
    }
}
 
Example 14
Source Project: gemfirexd-oss   Source File: DataSourcePropertiesTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Tests that the default password is not sent as an attribute string when
 * <code>attributesAsPassword</code> is <code>true</code>. The test is run
 * with an <code>XADataSource</code>.
 */
public void embeddedTestAttributesAsPasswordWithoutPassword_xa()
    throws Exception
{
    XADataSource ds = J2EEDataSource.getXADataSource();
    JDBCDataSource.setBeanProperty(ds, "password",  "mypassword");
    JDBCDataSource.setBeanProperty(ds, "attributesAsPassword", Boolean.TRUE);
    XAConnection xa = ds.getXAConnection();
    Connection c = xa.getConnection();
    c.close();
}
 
Example 15
Source Project: FHIR   Source File: TestEmbeddedXADataSource.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * We'll override this method so that we can insert our own class as a wrapper around the XAConnection served up by
 * the super class.
 */
@Override
public XAConnection getXAConnection() throws SQLException {
    log.entering(this.getClass().getName(), methodLabel("getXAConnection"));
    try {
        XAConnection conn = delegate.getXAConnection();
        String dsLabel = getDataSourceLabel();
        XAConnection result = new TestXAConnection(conn, dsLabel, failStep, failCount);
        return result;
    } finally {
        log.exiting(this.getClass().getName(), methodLabel("getXAConnection"));
    }
}
 
Example 16
Source Project: FHIR   Source File: TestXAConnection.java    License: Apache License 2.0 5 votes vote down vote up
public TestXAConnection(XAConnection conn, String dsLabel, String failStep, int failCount) {
    log.entering(this.getClass().getName(), "TestXAConnection ctor", new Object[] {
            "dsLabel", dsLabel, "failStep", failStep, "failCount", failCount
    });
    this.delegate = conn;
    this.failStep = failStep;
    this.failCount = failCount;
    this.dsLabel = dsLabel;
    log.exiting(this.getClass().getName(), "TestXAConnection ctor");
}
 
Example 17
Source Project: gemfirexd-oss   Source File: EmbeddedXADataSource.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Intantiate and return an EmbedXAConnection from this instance
 * of EmbeddedXADataSource.
 *
 * @param user 
 * @param password 
 * @return XAConnection
 */
protected XAConnection createXAConnection (ResourceAdapter ra, 
    String user, String password, boolean requestPassword)
    throws SQLException
{
    /* This object (EmbeddedXADataSource) is a JDBC 2 and JDBC 3
     * implementation of XADatSource.  However, it's possible that we
     * are running with a newer driver (esp. JDBC 4) in which case we
     * should return a PooledConnection that implements the newer JDBC
     * interfaces--even if "this" object does not itself satisfy those
     * interfaces.  As an example, if we have a JDK 6 application then
     * even though this specific object doesn't implement JDBC 4 (it
     * only implements JDBC 2 and 3), we should still return an
     * XAConnection object that *does* implement JDBC 4 because that's
     * what a JDK 6 app expects.
     *
     * By calling "findDriver()" here we will get the appropriate
     * driver for the JDK in use (ex. if using JDK 6 then findDriver()
     * will return the JDBC 4 driver).  If we then ask the driver to
     * give us an XA connection, we will get a connection that
     * corresponds to whatever driver/JDBC implementation is being
     * used--which is what we want.  So for a JDK 6 application we
     * will correctly return a JDBC 4 XAConnection. DERBY-2488.
     *
     * This type of scenario can occur if an application that was
     * previously running with an older JVM (ex. JDK 1.4/1.5) starts
     * running with a newer JVM (ex. JDK 6), in which case the app
     * is probably still using the "old" data source (ex. is still
     * instantiating EmbeddedXADataSource) instead of the newer one
     * (EmbeddedXADataSource40).
     */
    return ((Driver30) findDriver()).getNewXAConnection(
        this, ra, user, password, requestPassword);
}
 
Example 18
/**
 * Test that connections retrieved from {@code XADataSource} that are not
 * part of a global XA transaction, behave as expected when {@code close()}
 * is called and the transaction is active.
 */
public void testCloseActiveConnection_XA_local() throws SQLException {
    XADataSource ds = J2EEDataSource.getXADataSource();
    XAConnection xa = ds.getXAConnection();
    testCloseActiveConnection(xa.getConnection(), true, false);
    Connection c = xa.getConnection();
    c.setAutoCommit(false);
    testCloseActiveConnection(c, false, false);
    xa.close();
}
 
Example 19
public XAConnection getXAConnection(String user, String password) throws SQLException {
    if (internalDs == null) {
        initialize();
    }
    FBConnection connection = (FBConnection) internalDs.getConnection(user, password);
    return new FBXAConnection(connection);
}
 
Example 20
/**
 * Test the JDBC 4.1 Connection.abort(Executor) method on XA connections.
 */
public void testAbortXA() throws Exception
{
    //
    // In order to run this test, a special permission must be granted to
    // the jar file containing this method.
    //
    if ( !TestConfiguration.loadingFromJars() ) { return; }

    XADataSource xads = J2EEDataSource.getXADataSource();
    
    XAConnection conn0 = getXAConnection( xads, "user0");
    XAConnection conn1 = getXAConnection( xads, "user1");
    XAConnection conn2 = getXAConnection( xads, "user2");

    abortVetter( conn0.getConnection(), conn1.getConnection(), conn2.getConnection() );

    // verify that the underlying physical connection is closed
    try {
        conn1.getConnection();
        fail( "Expected physical connection to be closed." );
    }
    catch (SQLException se)
    {
        assertSQLState( CLOSED_CONNECTION, se );
    }
}
 
Example 21
Source Project: tomcatsrc   Source File: DataSourceProxy.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@link javax.sql.XADataSource#getXAConnection()}
 */
public XAConnection getXAConnection() throws SQLException {
    Connection con = getConnection();
    if (con instanceof XAConnection) {
        return (XAConnection)con;
    } else {
        try {con.close();} catch (Exception ignore){}
        throw new SQLException("Connection from pool does not implement javax.sql.XAConnection");
    }
}
 
Example 22
Source Project: gemfirexd-oss   Source File: EmbeddedXADataSource.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Intantiate and return an EmbedXAConnection from this instance
 * of EmbeddedXADataSource.
 *
 * @param user 
 * @param password 
 * @return XAConnection
 */
protected XAConnection createXAConnection (ResourceAdapter ra, 
    String user, String password, boolean requestPassword)
    throws SQLException
{
    /* This object (EmbeddedXADataSource) is a JDBC 2 and JDBC 3
     * implementation of XADatSource.  However, it's possible that we
     * are running with a newer driver (esp. JDBC 4) in which case we
     * should return a PooledConnection that implements the newer JDBC
     * interfaces--even if "this" object does not itself satisfy those
     * interfaces.  As an example, if we have a JDK 6 application then
     * even though this specific object doesn't implement JDBC 4 (it
     * only implements JDBC 2 and 3), we should still return an
     * XAConnection object that *does* implement JDBC 4 because that's
     * what a JDK 6 app expects.
     *
     * By calling "findDriver()" here we will get the appropriate
     * driver for the JDK in use (ex. if using JDK 6 then findDriver()
     * will return the JDBC 4 driver).  If we then ask the driver to
     * give us an XA connection, we will get a connection that
     * corresponds to whatever driver/JDBC implementation is being
     * used--which is what we want.  So for a JDK 6 application we
     * will correctly return a JDBC 4 XAConnection. DERBY-2488.
     *
     * This type of scenario can occur if an application that was
     * previously running with an older JVM (ex. JDK 1.4/1.5) starts
     * running with a newer JVM (ex. JDK 6), in which case the app
     * is probably still using the "old" data source (ex. is still
     * instantiating EmbeddedXADataSource) instead of the newer one
     * (EmbeddedXADataSource40).
     */
    return ((Driver30) findDriver()).getNewXAConnection(
        this, ra, user, password, requestPassword);
}
 
Example 23
private void    xa()        throws Exception
{
    XADataSource xads = J2EEDataSource.getXADataSource();
    
    XAConnection conn0 = getXAConnection( xads, "user6");
    XAConnection conn1 = getXAConnection( xads, "user7");
    XAConnection conn2 = getXAConnection( xads, "user8");

    vet( conn0.getConnection(), conn1.getConnection(), conn2.getConnection() );
}
 
Example 24
Source Project: gemfirexd-oss   Source File: DataSourcePropertiesTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Tests that the <code>attributesAsPassword</code> property of an
 * <code>XADataSource</code> causes an explicitly specified password to be
 * sent as a property string.
 */
public void embeddedTestAttributesAsPasswordWithPassword_xa()
    throws Exception
{
    XADataSource ds = J2EEDataSource.getXADataSource();
    JDBCDataSource.setBeanProperty(ds, "attributesAsPassword", Boolean.TRUE);
    try {
        XAConnection xa = ds.getXAConnection("username", "mypassword");
        fail("Expected getXAConnection to fail.");
    } catch (SQLException e) {
        // expect error because of malformed url
        assertSQLState("XJ028", e);
    }
}
 
Example 25
Source Project: evosql   Source File: JDBCXADataSource.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets a new XAConnection after validating the given username
 * and password.
 *
 * @param user String which must match the 'user' configured for this
 *             JDBCXADataSource.
 * @param password  String which must match the 'password' configured
 *                  for this JDBCXADataSource.
 *
 * @see #getXAConnection()
 */
public XAConnection getXAConnection(String user,
                                    String password) throws SQLException {

    if (user == null || password == null) {
        throw JDBCUtil.nullArgument();
    }

    if (user.equals(this.user) && password.equals(this.password)) {
        return getXAConnection();
    }

    throw JDBCUtil.sqlException(Error.error(ErrorCode.X_28000));
}
 
Example 26
public NetXAResource(XAConnection xaconn, int rmId,
                     String userId, String password,
                     com.splicemachine.db.client.net.NetXAConnection conn) {
    xaconn_ = xaconn;
    rmId_ = rmId;
    conn_ = conn.getNetConnection();
    netXAConn_ = conn;
    rmIdx_ = userId;
    rmIdy_ = password;
    port_ = conn_.netAgent_.getPort();
    ipaddr_ = conn_.netAgent_.socket_.getLocalAddress().getHostAddress();
    conn.setNetXAResource(this);

    // link the primary connection to the first XACallInfo element
    conn_.currXACallInfoOffset_ = 0;

    // construct the NetXACallInfo object for the array.
    for (int i = 0; i < INITIAL_CALLINFO_ELEMENTS; ++i) {
        callInfoArray_[i] = new NetXACallInfo(null, XAResource.TMNOFLAGS, this,
                null);
    }

    // initialize the first XACallInfo element with the information from the
    //  primary connection
    callInfoArray_[0].actualConn_ = conn;
    callInfoArray_[0].currConnection_ = true;
    callInfoArray_[0].freeEntry_ = false;
    // ~~~ save conn_ connection variables in callInfoArray_[0]
    callInfoArray_[0].saveConnectionVariables();
}
 
Example 27
Source Project: gemfirexd-oss   Source File: J2EEDataSourceTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Test that connections retrieved from {@code XADataSource} that are not
 * part of a global XA transaction, behave as expected when {@code close()}
 * is called and the transaction is active.
 */
public void testCloseActiveConnection_XA_local() throws SQLException {
    XADataSource ds = J2EEDataSource.getXADataSource();
    XAConnection xa = ds.getXAConnection();
    testCloseActiveConnection(xa.getConnection(), true, false);
    Connection c = xa.getConnection();
    c.setAutoCommit(false);
    testCloseActiveConnection(c, false, false);
}
 
Example 28
Source Project: Komondor   Source File: MysqlXADataSource.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Wraps a connection as a 'fake' XAConnection
 */

private XAConnection wrapConnection(Connection conn) throws SQLException {
    if (getPinGlobalTxToPhysicalConnection() || ((com.mysql.jdbc.Connection) conn).getPinGlobalTxToPhysicalConnection()) {
        return SuspendableXAConnection.getInstance((com.mysql.jdbc.Connection) conn);
    }

    return MysqlXAConnection.getInstance((com.mysql.jdbc.Connection) conn, getLogXaCommands());
}
 
Example 29
Source Project: scipio-erp   Source File: TransactionUtil.java    License: Apache License 2.0 5 votes vote down vote up
/** Enlists the given XAConnection and if a transaction is active in the current thread, returns a plain JDBC Connection */
public static Connection enlistConnection(XAConnection xacon) throws GenericTransactionException {
    if (xacon == null) {
        return null;
    }
    try {
        XAResource resource = xacon.getXAResource();
        TransactionUtil.enlistResource(resource);
        return xacon.getConnection();
    } catch (SQLException e) {
        throw new GenericTransactionException("SQL error, could not enlist connection in transaction even though transactions are available", e);
    }
}
 
Example 30
Source Project: gemfirexd-oss   Source File: XATransactionTest.java    License: Apache License 2.0 5 votes vote down vote up
public void testSimpleXATransaction() throws Exception {
  Statement stm = getConnection().createStatement();
  stm.execute("create table XATT2 (i int, text char(10))");

  XADataSource xaDataSource = (XADataSource)TestUtil.getXADataSource(TestUtil.EmbeddedeXADsClassName);
  // create large enough xid
  byte[] gid = new byte[64];
  byte[] bid = new byte[64];
  for (int i = 0; i < 64; i++) {
    gid[i] = (byte)i;
    bid[i] = (byte)(64 - i);
  }
  Xid xid = new ClientXid(0x1234, gid, bid);

  // get the stuff required to execute the global transaction
  XAConnection xaConn = xaDataSource.getXAConnection();
  XAResource xaRes = xaConn.getXAResource();
  Connection conn = xaConn.getConnection();
  conn.setTransactionIsolation(getIsolationLevel());
  // start the transaction with that xid
  xaRes.start(xid, XAResource.TMNOFLAGS);

  // do some work
  stm = conn.createStatement();
  stm.execute("insert into XATT2 values (1234, 'Test_Entry')");
  stm.close();

  stm = getConnection().createStatement();
  stm.execute("select * from XATT2");
  ResultSet rs = stm.getResultSet();
  assertFalse(rs.next());
  // end the work on the transaction branch
  xaRes.end(xid, XAResource.TMSUCCESS);
  xaRes.prepare(xid);
  xaRes.commit(xid, false);
  stm.execute("select * from XATT2");
  rs = stm.getResultSet();
  assertTrue(rs.next());
}