Package javax.sql

Examples of javax.sql.XAConnection


     * XAException.XAER_RMFAIL. Lesser exceptions map to XAException.XAER_RMERR
     * @throws Exception
     */
    public void testXAExceptionErrorCodeOnSQLExceptionDerby4141() throws Exception {
        XADataSource xaDataSource = J2EEDataSource.getXADataSource();
        XAConnection xaConn = xaDataSource.getXAConnection();
        XAResource xaRes = xaConn.getXAResource();       
        Xid xid = createXid(123, 1);
        // close the XAConnection so we get an SQLException on
        // start();
        xaConn.close();
        try {
            xaRes.start(xid, XAResource.TMNOFLAGS);
            fail("Should have gotten an XAException. xaConn is closed.");
        } catch (XAException xae) {
            assertEquals(XAException.XAER_RMFAIL, xae.errorCode);
View Full Code Here


   
    private transient TransactionManager tm;
   
    public Connection getConnection() throws SQLException
    {
      XAConnection xaConn = wrappedDS.getXAConnection();
      Connection conn = getEnlistedConnection(xaConn);
     
      return conn;
    }
View Full Code Here

      return conn;
    }

    public Connection getConnection(String username, String password) throws SQLException
    {
      XAConnection xaConn = wrappedDS.getXAConnection(username, password);
      Connection conn = getEnlistedConnection(xaConn);
     
      return conn;
    }
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 xacon = xa.getXAConnection();
            if (!synchronizationRegistered.get()) {
                if (transactionManager.getTransaction() != null && transactionActive(transactionManager.getTransaction().getStatus())) {
                    transactionManager.getTransaction().enlistResource(xacon.getXAResource());
                    synchronizationRegistry.registerInterposedSynchronization(this);
                    synchronizationRegistered.set(true);
                }
            }
            return xacon.getConnection();
        } else {
            final Object ret = method.invoke(delegate, args);
            return ret;
        }
    }
View Full Code Here

                    Connection con;

                    if (ds instanceof XADataSource) {
                        if (Debug.infoOn()) Debug.logInfo("Got XADataSource for name " + jndiName, module);
                        XADataSource xads = (XADataSource) ds;
                        XAConnection xac = xads.getXAConnection();

                        con = TransactionUtil.enlistConnection(xac);
                    } else {
                        if (Debug.infoOn()) Debug.logInfo("Got DataSource for name " + jndiName, module);
View Full Code Here

    throws SQLException
  {
    long start = start();
   
    try {
      XAConnection conn = _dataSource.getXAConnection();

      String connId = _id + "." + _connCount++;

      log(start, "getXAConnection() -> " + connId + ":" + conn);
View Full Code Here

    throws SQLException
  {
    long start = start();
   
    try {
      XAConnection conn = _dataSource.getXAConnection(user, password);

      String connId = _id + "." + _connCount++;

      log(start, "getXAConnection(" + user + ") -> " + connId + ":" + conn);
View Full Code Here

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

        // Test chinese database name.
        XADataSource ds = J2EEDataSource.getXADataSource();
        J2EEDataSource.setBeanProperty(ds, "databaseName", "\u4e10");
        J2EEDataSource.setBeanProperty(ds, "createDatabase", "create");       
        try {
            XAConnection xaconn = ds.getXAConnection();
            Connection conn = xaconn.getConnection();
            conn.close();
        } catch (SQLException se ) {
            if (usingEmbedded())
                throw se;
            else
                assertSQLState("22005",se);
        }  
        // Chinese user
        try {
            J2EEDataSource.setBeanProperty(ds, "user", "\u4e10");
            XAConnection xaconn = ds.getXAConnection();
            Connection conn = xaconn.getConnection();
            conn.close();
        } catch (SQLException se ) {
            if (usingEmbedded())
                throw se;
            else
                assertSQLState("22005",se);
        }
        // Chinese password
        try {
            J2EEDataSource.setBeanProperty(ds, "password", "\u4e10");
            XAConnection xaconn = ds.getXAConnection();
            Connection conn = xaconn.getConnection();
            conn.close();
        } catch (SQLException se ) {
            if (usingEmbedded())
                throw se;
            else
View Full Code Here

        }
       
        @Override
        protected XAConnection getPhysicalConnection(CredentialExtractor credentialExtractor)
            throws ResourceException {
            XAConnection connection = super.getPhysicalConnection(credentialExtractor);
            int isolationLevel = dataSourceDescription.getIsolationLevel();
            if (isolationLevel != -1) {
                try {
                    connection.getConnection().setTransactionIsolation(isolationLevel);
                } catch (SQLException e) {
                    throw new ResourceException("Error setting transaction isolation level for ", dataSourceDescription.getName());
                }
            }
            return connection;
View Full Code Here

TOP

Related Classes of javax.sql.XAConnection

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.