Package javax.sql

Examples of javax.sql.XADataSource


    /**
     * Derby-966 holdability and global/location transactions. (work in
     * progress)
     */
    public void testDerby966() throws SQLException, XAException {
        XADataSource xads = J2EEDataSource.getXADataSource();
        XAConnection xac = xads.getXAConnection();
        XAResource xar = xac.getXAResource();

        Xid xid = XATestUtil.getXid(996, 9, 48);

        Connection conn = xac.getConnection();
View Full Code Here


        cpds = null;

        // now with XADataSource
//        EmbeddedXADataSource xads = new EmbeddedXADataSource();
        String xadsName = dsclient.getXADataSourceClassName();
        XADataSource xads =
                (XADataSource) Class.forName(xadsName).newInstance();

        // XADataSource - EMPTY
        dsConnectionRequests(new String[] { 
            "08006","08006","08006","08006",
View Full Code Here

        JDBCDataSource.setBeanProperty(cpds, "traceFile", traceFile);
        ((ClientConnectionPoolDataSource) cpds).getConnection();
        cpds = null;

        // now with XADataSource
        XADataSource xads = J2EEDataSource.getXADataSource();

        traceFile = "trace5.out";
        JDBCDataSource.setBeanProperty(xads, "connectionAttributes",
            "traceFile="+traceFile);
        ((ClientXADataSource) xads).getConnection();
View Full Code Here

        // leaves the database is a bad state which results in a
        // network protocol error
        if (usingDerbyNetClient())
            return;
        // START XA HOLDABILITY TEST
        XADataSource dscsx = J2EEDataSource.getXADataSource();

        XAConnection xac = dscsx.getXAConnection();
        XAResource xr = xac.getXAResource();
        Xid xid = new cdsXid(25, (byte) 21, (byte) 01);
        Connection conn1 = xac.getConnection();
        // check that autocommit is true; default for a connection
        assertTrue(conn1.getAutoCommit());
View Full Code Here

        pc1.close();
    }
   
    public void timeoutTestDerby1144XADS() throws SQLException {
      
        XADataSource xds = J2EEDataSource.getXADataSource();
        // Test xa connection isolation
        XAConnection xpc1 = xds.getXAConnection();       
        assertPooledConnIso("XAConnection", xpc1);                
        xpc1.close();
    }
View Full Code Here

        ConnectionPoolDataSource cpds =
            J2EEDataSource.getConnectionPoolDataSource();
        subtestCloseEventWithNullListener(cpds.getPooledConnection());
        subtestErrorEventWithNullListener(cpds.getPooledConnection());

        XADataSource xads = J2EEDataSource.getXADataSource();
        subtestCloseEventWithNullListener(xads.getXAConnection());
        subtestErrorEventWithNullListener(xads.getXAConnection());
    }
View Full Code Here

     * 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);
    }
View Full Code Here

     * 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
View Full Code Here

        // DERBY-3401 - removing a callback during a close causes problems.
        subtestPooledRemoveListenerOnClose(cpds.getPooledConnection());
        subtestPooledAddListenerOnClose(cpds.getPooledConnection());

      // PooledConnection from an XDataSource
      XADataSource xads = J2EEDataSource.getXADataSource();
      subtestPooledReuseOnClose(xads.getXAConnection());
        subtestPooledCloseOnClose(xads.getXAConnection());
        // DERBY-3401 - removing a callback during a close causes problems.
        subtestPooledRemoveListenerOnClose(xads.getXAConnection());
        subtestPooledAddListenerOnClose(xads.getXAConnection());
    }
View Full Code Here

        //Check if got connection closed event but not connection error event
        assertTrue(aes1.didConnectionClosedEventHappen());
        assertFalse(aes1.didConnectionErrorEventHappen());
        aes1.resetState();

        XADataSource dsx = J2EEDataSource.getXADataSource();

        if (usingEmbedded())
            assertToString(dsx);

        // shutdown db and check all's still ok thereafter
        TestConfiguration.getCurrent().shutdownDatabase();

        dmc = getConnection();
        cs = dmc.prepareCall("call checkConn2(?)");
        // checks currently only implemented for embedded
        if (usingEmbedded())
        {
            SecurityCheck.assertSourceSecurity(
                cs, "java.sql.CallableStatement");
        }
        cs.setString(1,"Nested");
        try {
            cs.execute();
        } catch (SQLException sqle) {
            assertSQLState("40XC0", sqle);
        }
        cs.setString(1, "Nested2");
        cs.execute();

        XAConnection xac = dsx.getXAConnection();
        // checks currently only implemented for embedded
        if (usingEmbedded())
        {
            SecurityCheck.assertSourceSecurity(xac, "javax.sql.XAConnection");
        }
        AssertEventCatcher aes3 = new AssertEventCatcher(3);
        xac.addConnectionEventListener(aes3);
        assertConnectionOK(
            expectedValues, "XADataSource", xac.getConnection());
        //Check if got connection closed event but not connection error event
        assertTrue(aes3.didConnectionClosedEventHappen());
        assertFalse(aes3.didConnectionErrorEventHappen());
        aes3.resetState();
                      
        pc = dsp.getPooledConnection();
        AssertEventCatcher aes2 = new AssertEventCatcher(2);
        pc.addConnectionEventListener(aes2);
        assertConnectionOK(
            expectedValues, "ConnectionPoolDataSource", pc.getConnection());
        //Check if got connection closed event but not connection error event
        assertTrue(aes2.didConnectionClosedEventHappen());
        assertFalse(aes2.didConnectionErrorEventHappen());
        aes2.resetState();

        // test "local" XAConnections
        xac = dsx.getXAConnection();
        AssertEventCatcher aes4 = new AssertEventCatcher(4);
        xac.addConnectionEventListener(aes4);
        assertConnectionOK(
            expectedValues, "XADataSource", xac.getConnection());
        //Check if got connection closed event but not connection error event
        assertTrue(aes4.didConnectionClosedEventHappen());
        assertFalse(aes4.didConnectionErrorEventHappen());
        aes4.resetState();
        assertConnectionOK(
            expectedValues, "XADataSource", xac.getConnection());
        //Check if got connection closed event but not connection error event
        assertTrue(aes4.didConnectionClosedEventHappen());
        assertFalse(aes4.didConnectionErrorEventHappen());
        aes4.resetState();
        xac.close();

        // test "global" XAConnections
        xac = dsx.getXAConnection();
        AssertEventCatcher aes5 = new AssertEventCatcher(5);
        xac.addConnectionEventListener(aes5);
        XAResource xar = xac.getXAResource();
        // checks currently only implemented for embedded
        if (usingEmbedded())
View Full Code Here

TOP

Related Classes of javax.sql.XADataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.