Package javax.sql

Examples of javax.sql.XADataSource


     * sent as a property string.
     */
    public void embeddedTestAttributesAsPasswordWithPassword_xa()
        throws Exception
    {
        XADataSource ds = TestDataSourceFactory.getXADataSource();
        setDataSourceProperty(ds, "attributesAsPassword", Boolean.TRUE,
                              Boolean.TYPE);
        try {
            XAConnection xa = ds.getXAConnection("username", "mypassword");
            fail("Expected getXAConnection to fail.");
        } catch (SQLException e) {
            // expect error because of malformed url
            assertSQLState("XJ028", e);
        }
View Full Code Here


        protected ConnectionFactory createConnectionFactory() throws SQLException {

            if (dataSource instanceof XADataSource) {

                // Create the XAConectionFactory using the XA data source
                XADataSource xaDataSourceInstance = (XADataSource) dataSource;
                XAConnectionFactory xaConnectionFactory = new DataSourceXAConnectionFactory(getTransactionManager(), xaDataSourceInstance, username, password);
                setTransactionRegistry(xaConnectionFactory.getTransactionRegistry());
                return xaConnectionFactory;

            } else {
View Full Code Here

         *
         * @return a <code>Connection</code> value
         * @exception SQLException if an error occurs
         */
        protected Connection newConnection_() throws SQLException {
            XADataSource ds = TestDataSourceFactory.getXADataSource();
            XAConnection xac = ds.getXAConnection(TestConfiguration.getCurrent().getUserName(),
                    TestConfiguration.getCurrent().getUserPassword());
            return xac.getConnection();
        }
View Full Code Here

    System.out.println("START XA HOLDABILITY TEST");
    try {
      Properties attrs = new Properties();
      attrs.setProperty("databaseName", "wombat");
      attrs.setProperty("connectionAttributes", "create=true");
      XADataSource dscsx =  TestUtil.getXADataSource(attrs);
   
      XAConnection xac = dscsx.getXAConnection("fred", "wilma");
      XAResource xr = xac.getXAResource();
      Xid xid = getXid(25, (byte) 21, (byte) 01);
      Connection conn1 = xac.getConnection();
      System.out.println("By default, autocommit is " + conn1.getAutoCommit() + " for a connection");
      System.out.println("Default holdability for a connection is HOLD_CURSORS_OVER_COMMIT");
View Full Code Here

    pc1 = ds.getPooledConnection();
    testPooledConnIso("PooledConnection" , pc1);  
        pc1.close();
      
        // Test xa connection isolation
    XADataSource xds = TestUtil.getXADataSource(p);
      XAConnection xpc1 = xds.getXAConnection();       
        testPooledConnIso("XAConnection", xpc1);                
        xpc1.close();
      }
View Full Code Here

        Properties properties = new Properties();
        InputStream is = new ByteArrayInputStream(propertiesString.getBytes());
        properties.load(is);

        Class clazz = Thread.currentThread().getContextClassLoader().loadClass(xaDataSourceClassname);
        XADataSource xads = (XADataSource) clazz.newInstance();
        Class[] NOCLASSES = new Class[] {};
        for (Iterator i = properties.keySet().iterator(); i.hasNext();)
        {
            String name = (String) i.next();
            String value = properties.getProperty(name);
View Full Code Here

    }

    @Override
    public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
        if (method.getName().equals("getConnection") && method.getParameterTypes().length == 0 && delegate instanceof XADataSource) {
            final XADataSource xa = (XADataSource) delegate;
            final XAConnection xaConn = xa.getXAConnection();
            final Object transactionKey = synchronizationRegistry.getTransactionKey();
            if (!registeredTransactions.contains(transactionKey)) {
                if (transactionManager.getTransaction() != null && transactionActive(transactionManager.getTransaction().getStatus())) {
                    transactionManager.getTransaction().enlistResource(xaConn.getXAResource());
                    synchronizationRegistry.registerInterposedSynchronization(new Sync(transactionKey));
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);
        xa.close();
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

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.