コード例 #1
0
    @Override
    protected ManagedConnectionFactory createMcf(
        org.jboss.jca.common.api.metadata.ds.DataSource arg0, String arg1, ClassLoader arg2)
        throws NotFoundException, DeployException {
      final LocalManagedConnectionFactory managedConnectionFactory =
          new LocalManagedConnectionFactory();
      managedConnectionFactory.setUserTransactionJndiName("java:comp/UserTransaction");
      managedConnectionFactory.setDriverClass(dataSourceConfig.getDriverClass());

      if (dataSourceConfig.getConnectionProperties() != null) {
        managedConnectionFactory.setConnectionProperties(
            buildConfigPropsString(dataSourceConfig.getConnectionProperties()));
      }
      if (dataSourceConfig.getConnectionUrl() != null) {
        managedConnectionFactory.setConnectionURL(dataSourceConfig.getConnectionUrl());
      }

      if (dataSourceConfig.getNewConnectionSql() != null) {
        managedConnectionFactory.setNewConnectionSQL(dataSourceConfig.getNewConnectionSql());
      }

      if (dataSourceConfig.getUrlSelectorStrategyClassName() != null) {
        managedConnectionFactory.setUrlSelectorStrategyClassName(
            dataSourceConfig.getUrlSelectorStrategyClassName());
      }
      setMcfProperties(managedConnectionFactory, dataSourceConfig, dataSourceConfig.getStatement());

      return managedConnectionFactory;
    }
コード例 #2
0
  public static DataSource newDataSource(
      String driverClass, String connURL, String user, String password) throws ResourceException {

    LocalManagedConnectionFactory mcf = new LocalManagedConnectionFactory();

    mcf.setDriverClass(driverClass);
    mcf.setConnectionURL(connURL);
    mcf.setUserName(user);
    mcf.setPassword(password);

    NoTxConnectionManagerImpl cm = new NoTxConnectionManagerImpl();
    OnePool pool = new OnePool(mcf, new PoolConfiguration(), false);
    pool.setConnectionListenerFactory(cm);
    cm.setPool(pool);

    return (DataSource) mcf.createConnectionFactory(cm);
  }
コード例 #3
0
    @Override
    protected ManagedConnectionFactory createMcf(
        org.jboss.jca.common.api.metadata.ds.DataSource arg0, String arg1, ClassLoader arg2)
        throws NotFoundException, DeployException {
      final LocalManagedConnectionFactory managedConnectionFactory =
          new LocalManagedConnectionFactory();
      managedConnectionFactory.setDriverClass(dataSourceConfig.getDriverClass());

      if (dataSourceConfig.getUrlDelimiter() != null) {
        try {
          managedConnectionFactory.setURLDelimiter(dataSourceConfig.getUrlDelimiter());
        } catch (Exception e) {
          throw ConnectorLogger.ROOT_LOGGER.failedToGetUrlDelimiter(e);
        }
      }

      if (dataSourceConfig.getDataSourceClass() != null) {
        managedConnectionFactory.setDataSourceClass(dataSourceConfig.getDataSourceClass());
      }

      if (dataSourceConfig.getConnectionProperties() != null) {
        managedConnectionFactory.setConnectionProperties(
            buildConfigPropsString(dataSourceConfig.getConnectionProperties()));
      }
      if (dataSourceConfig.getConnectionUrl() != null) {
        managedConnectionFactory.setConnectionURL(dataSourceConfig.getConnectionUrl());
      }

      if (dataSourceConfig.getNewConnectionSql() != null) {
        managedConnectionFactory.setNewConnectionSQL(dataSourceConfig.getNewConnectionSql());
      }

      if (dataSourceConfig.getUrlSelectorStrategyClassName() != null) {
        managedConnectionFactory.setUrlSelectorStrategyClassName(
            dataSourceConfig.getUrlSelectorStrategyClassName());
      }
      setMcfProperties(managedConnectionFactory, dataSourceConfig, dataSourceConfig.getStatement());

      return managedConnectionFactory;
    }