Examples of PoolingDataSource


Examples of bitronix.tm.resource.jdbc.PoolingDataSource

        TransactionManagerServices.getTransactionManager();

        MockitoXADataSource.setStaticCloseXAConnectionException(null);
        MockitoXADataSource.setStaticGetXAConnectionException(null);

        pds = new PoolingDataSource();
        pds.setMinPoolSize(1);
        pds.setMaxPoolSize(2);
        pds.setMaxIdleTime(1);
        pds.setClassName(MockitoXADataSource.class.getName());
        pds.setUniqueName("pds");
View Full Code Here

Examples of bitronix.tm.resource.jdbc.PoolingDataSource

    }

    public void testInitFailure() throws Exception {
        pds.close();

        pds = new PoolingDataSource();
        pds.setMinPoolSize(0);
        pds.setMaxPoolSize(2);
        pds.setMaxIdleTime(1);
        pds.setClassName(MockitoXADataSource.class.getName());
        pds.setUniqueName("pds");
View Full Code Here

Examples of bitronix.tm.resource.jdbc.PoolingDataSource

    public void testPoolNotStartingTransactionManager() throws Exception {
        // make sure TM is not running
        TransactionManagerServices.getTransactionManager().shutdown();
       
        PoolingDataSource pds = new PoolingDataSource();
        pds.setMinPoolSize(1);
        pds.setMaxPoolSize(2);
        pds.setMaxIdleTime(1);
        pds.setClassName(MockitoXADataSource.class.getName());
        pds.setUniqueName("pds2");
        pds.setAllowLocalTransactions(true);
        pds.setAcquisitionTimeout(1);
        pds.init();

        assertFalse(TransactionManagerServices.isTransactionManagerRunning());

        Connection c = pds.getConnection();
        Statement stmt = c.createStatement();
        stmt.close();
        c.close();

        assertFalse(TransactionManagerServices.isTransactionManagerRunning());

        pds.close();

        assertFalse(TransactionManagerServices.isTransactionManagerRunning());
    }
View Full Code Here

Examples of org.apache.commons.dbcp.PoolingDataSource

    // factory to this.  (So despite how it may appear, all of the objects
    // declared in this method are incorporated into the returned result.)
    //
    new PoolableConnectionFactory(
        connectionFactory, connectionPool, null, null, false, true);
    return new PoolingDataSource(connectionPool);
  }
View Full Code Here

Examples of org.apache.commons.dbcp.PoolingDataSource

    objectPool.setTestWhileIdle(true);
    objectPool.setTimeBetweenEvictionRunsMillis(60 * 1000L);
    PoolableObjectFactory factory = new PoolableConnectionFactory(connectionFactory, objectPool, null,
        "SELECT 1", false, false);
    objectPool.setFactory(factory);
    delegate = new PoolingDataSource(objectPool);
  }
View Full Code Here

Examples of org.apache.commons.dbcp.PoolingDataSource

           
            ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectURI, user, password);
           
            dsConnectionFactory = new PoolableConnectionFactory(connectionFactory, connectionPool, null, null, false, true);
           
            dataSource = new PoolingDataSource(connectionPool);           
           
            log.info("DBCPCDatasourceComponent successfuly started!");
        }
        catch (Throwable e)
        {
View Full Code Here

Examples of org.apache.commons.dbcp.PoolingDataSource

      else
      {
        whenExhaustedActionType = GenericObjectPool.WHEN_EXHAUSTED_BLOCK;
      }

      final PoolingDataSource poolingDataSource = new PoolingDataSource();
      final Driver driver = ObjectUtilities.loadAndInstantiate(driverClass, PooledDatasourceHelper.class, Driver.class);

      // As the name says, this is a generic pool; it returns  basic Object-class objects.
      final GenericObjectPool pool = new GenericObjectPool(null);
      pool.setWhenExhaustedAction(whenExhaustedActionType);

      // Tuning the connection pool
      pool.setMaxActive(maxActiveConnection);
      pool.setMaxIdle(maxIdleConnection);
      pool.setMaxWait(waitTime);
      pool.setMinIdle(minIdleConnection);
      pool.setTestWhileIdle(testWhileIdle);
      pool.setTestOnReturn(testOnReturn);
      pool.setTestOnBorrow(testOnBorrow);
      pool.setTestWhileIdle(testWhileIdle);
      /*
      ConnectionFactory creates connections on behalf of the pool.
      Here, we use the DriverManagerConnectionFactory because that essentially
      uses DriverManager as the source of connections.
      */
      final Properties properties = new Properties();
      properties.setProperty("user", databaseConnection.getUsername());
      properties.setProperty("password", databaseConnection.getPassword());
      final ConnectionFactory factory = new DriverConnectionFactory(driver, url, properties);

      /*
      Puts pool-specific wrappers on factory connections.  For clarification:
      "[PoolableConnection]Factory," not "Poolable[ConnectionFactory]."
      */
      // This declaration is used implicitly.
      //noinspection UnusedDeclaration
      final PoolableConnectionFactory pcf = new PoolableConnectionFactory(factory, // ConnectionFactory
          pool, // ObjectPool
          null, // KeyedObjectPoolFactory
          validQuery, // String (validation query)
          false, // boolean (default to read-only?)
          true // boolean (default to auto-commit statements?)
      );

      /*
      initialize the pool to X connections
      */
      logger.debug("Pool defaults to " + maxActiveConnection + " max active/" + maxIdleConnection + "max idle" + "with " + waitTime + "wait time"//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
          + " idle connections."); //$NON-NLS-1$

      for (int i = 0; i < maxIdleConnection; ++i)
      {
        pool.addObject();
      }
      logger.debug("Pool now has " + pool.getNumActive() + " active/" + pool.getNumIdle() + " idle connections."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      /*
      All of this is wrapped in a DataSource, which client code should
      already know how to handle (since it's the same class of object
      they'd fetch via the container's JNDI tree
      */
      poolingDataSource.setPool(pool);

      // store the pool, so we can get to it later
      cacheManager.getDataSourceCache().put(databaseConnection.getName(), poolingDataSource);
      return (poolingDataSource);
    }
View Full Code Here

Examples of org.apache.commons.dbcp.PoolingDataSource

    final HashMap<String, String> attrs = new HashMap<String, String>();
    attrs.put(DatabaseConnection.ATTRIBUTE_CUSTOM_DRIVER_CLASS, "org.hsqldb.jdbcDriver");
    attrs.put(DatabaseConnection.ATTRIBUTE_CUSTOM_URL, "jdbc:hsqldb:mem:SampleData");
    con.setAttributes(attrs);

    final PoolingDataSource poolingDataSource = PooledDatasourceHelper.setupPooledDataSource(con);
    final Connection connection = poolingDataSource.getConnection();
    connection.close();

  }
View Full Code Here

Examples of org.apache.commons.dbcp.PoolingDataSource

    // the "real" Connections created by the ConnectionFactory with
    // the classes that implement the pooling functionality.
    //
    new PoolableConnectionFactory(connectionFactory, connectionPool, null, null, false, true);

    PoolingDataSource dataSource = new PoolingDataSource(connectionPool);

    return dataSource;
  }
View Full Code Here

Examples of org.apache.commons.dbcp.PoolingDataSource

        ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(
                jdbcUrl, user, pass);
        PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(
                connectionFactory, connectionPool, null, null, false, true);

        dataSource = new PoolingDataSource(connectionPool);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.