Package com.taobao.datasource.resource

Examples of com.taobao.datasource.resource.JBossResourceException


         buffer.append("Missing configuration for HA local datasource. ");
         if (getConnectionURL() == null)
            buffer.append("No connection-url. ");
         if (urlDelimiter == null)
            buffer.append("No url-delimiter. ");
         throw new JBossResourceException(buffer.toString());
      }

      // try to get a connection as many times as many urls we have in the list
      for(int i = 0; i < urlSelector.getUrlList().size(); ++i)
      {
         String url = urlSelector.getUrl();

         if(trace)
         {
            log.trace("Trying to create a connection to " + url);
         }

         try
         {
            Driver d = getDriver(url);
            Connection con = d.connect(url, copy);
            if(con == null)
            {
               log.warn("Wrong driver class for this connection URL: " + url);
               urlSelector.failedUrl(url);
            }
            else
            {
               return new LocalManagedConnection(this, con, props, transactionIsolation, preparedStatementCacheSize);
            }
         }
         catch(Exception e)
         {
            log.warn("Failed to create connection for " + url + ": " + e.getMessage());
            urlSelector.failedUrl(url);
         }
      }

      // we have supposedly tried all the urls
      throw new JBossResourceException(
         "Could not create connection using any of the URLs: " + urlSelector.getUrlList()
      );
   }
View Full Code Here


      {
         String url = getConnectionURL();
         Driver d = getDriver(url);
         Connection con = d.connect(url, copy);
         if (con == null)
            throw new JBossResourceException("Wrong driver class for this connection URL");

         return new LocalManagedConnection(this, con, props, transactionIsolation, preparedStatementCacheSize);
      }
      catch (Exception e)
      {
         throw new JBossResourceException("Could not create connection", e);
      }
   }
View Full Code Here

      if (trace)
         log.trace("Checking driver for URL: " + url);

      if (driverClass == null)
      {
         throw new JBossResourceException("No Driver class specified!");
      }

      // Check if the driver is already loaded, if not then try to load it

      if (isDriverLoadedForURL(url))
      {
         return driver;
      } // end of if ()

      try
      {
         //try to load the class... this should register with DriverManager.
         Class clazz = Class.forName(driverClass, true, Thread.currentThread().getContextClassLoader());
         if (isDriverLoadedForURL(url))
            //return immediately, some drivers (Cloudscape) do not let you create an instance.
            return driver;

         //We loaded the class, but either it didn't register
         //and is not spec compliant, or is the wrong class.
         driver = (Driver) clazz.newInstance();
         DriverManager.registerDriver(driver);
         if (isDriverLoadedForURL(url))
            return driver;
         //We can even instantiate one, it must be the wrong class for the URL.
      }
      catch (Exception e)
      {
         throw new JBossResourceException("Failed to register driver for: " + driverClass, e);
      }

      throw new JBossResourceException("Apparently wrong driver class specified for URL: class: " + driverClass
            + ", url: " + url);
   }
View Full Code Here

      }
      catch (Throwable t)
      {
         if (trace)
            log.trace("Could not enlist in transaction on entering meta-aware object! " + cl, t);
         throw new JBossResourceException("Could not enlist in transaction on entering meta-aware object!", t);
      }
   }
View Full Code Here

  public Object createConnectionFactory(ConnectionManager cm) throws ResourceException {
    return new WrapperDataSource(this, cm);
  }

  public Object createConnectionFactory() throws ResourceException {
    throw new JBossResourceException("NYI");
  }
View Full Code Here

   * <p>In fact, we have a problem here. Theoretically, there is a possible
   * name collision between config properties and "user"/"password".
   */
  protected Properties getConnectionProperties(Subject subject, ConnectionRequestInfo cri) throws ResourceException {
    if (cri != null && cri.getClass() != WrappedConnectionRequestInfo.class)
      throw new JBossResourceException("Wrong kind of ConnectionRequestInfo: " + cri.getClass());

    Properties props = new Properties();
    props.putAll(connectionProps);
    if (subject != null) {
      if (SubjectActions.addMatchingProperties(subject, props, this) == true)
        return props;
      throw new JBossResourceException("No matching credentials in Subject!");
    }
    WrappedConnectionRequestInfo lcri = (WrappedConnectionRequestInfo) cri;
    if (lcri != null) {
      props.setProperty("user", (lcri.getUserName() == null) ? "" : lcri.getUserName());
      props.setProperty("password", (lcri.getPassword() == null) ? "" : lcri.getPassword());
View Full Code Here

   }

   public void associateConnection(Object handle) throws ResourceException
   {
      if (!(handle instanceof WrappedConnection))
         throw new JBossResourceException("Wrong kind of connection handle to associate" + handle);
      ((WrappedConnection)handle).setManagedConnection(this);
      synchronized(handles)
      {
         handles.add(handle);
      }
View Full Code Here

      throws ResourceException
   {
      Properties newProps = mcf.getConnectionProperties(subject, cri);
      if (!props.equals(newProps))
      {
         throw new JBossResourceException("Wrong credentials passed to getConnection!");
      } // end of if ()
   }
View Full Code Here

   }

   protected void checkException(SQLException e) throws ResourceException
   {
      connectionError(e);
      throw new JBossResourceException("SQLException", e);
   }
View Full Code Here

         String url = getConnectionURL();
         log.warn("Trying to create a connection to " + url);
         Driver d = getDriver(url);
         Connection con = d.connect(url, copy);
         if (con == null)
            throw new JBossResourceException("Wrong driver class for this connection URL");

         return new LocalManagedConnection(this, con, props, transactionIsolation, preparedStatementCacheSize);
      }
      catch (Exception e)
      {
         throw new JBossResourceException("Could not create connection", e);
      }
   }
View Full Code Here

TOP

Related Classes of com.taobao.datasource.resource.JBossResourceException

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.