Package org.apache.commons.dbcp

Examples of org.apache.commons.dbcp.PoolableConnectionFactory


        //
        // Now we'll create the PoolableConnectionFactory, which wraps
        // the "real" Connections created by the ConnectionFactory with
        // the classes that implement the pooling functionality.
        //
        PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,connectionPool,null,null,false,true);

        //
        // Finally, we create the PoolingDriver itself...
        //
        Class.forName("org.apache.commons.dbcp.PoolingDriver");
View Full Code Here


        conn.close();
       
        // construct pooling datasource
        connectionPool = new GenericObjectPool(null, 0, GenericObjectPool.WHEN_EXHAUSTED_GROW, 0, 5);
        ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(dbUri, dbUser, dbPassword);
        new PoolableConnectionFactory(connectionFactory, connectionPool, null, null, false, true);
        DataSource dataSource = new PoolingDataSource(connectionPool);           
       
        // create JNDI context
        rootContext = new InitialContext();
        Context namingContext = lookupOrCreateNamingContext(rootContext, "java:comp");
View Full Code Here

    connectionPool.setMaxActive(maxActive);

    statementPool = new GenericKeyedObjectPoolFactory(null);

    // Creating the factory instance automatically wires the connection pool
    new PoolableConnectionFactory(connFactory, connectionPool, statementPool,
        databaseType.getValidationQuery(), false, false,
        txIsolationLevel.getCode());

    dataSource = new PoolingDataSource(connectionPool);
View Full Code Here

        //
        // Now we'll create the PoolableConnectionFactory, which wraps
        // the "real" Connections created by the ConnectionFactory with
        // the classes that implement the pooling functionality.
        //
        final PoolableConnectionFactory poolableConnectionFactory;
        poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,
                connectionPool,
                statementPoolFactory,
                validationQuery,
                defaultReadOnly,
                defaultAutoCommit,
                ac);
        return poolableConnectionFactory.getPool();
    }
View Full Code Here

    // create the PoolableConnectionFactory, which wraps
    // the "real" Connections created by the ConnectionFactory
    // with the classes that implement the pooling functionality.
    try {
      PoolableConnectionFactory pcf =
        new PoolableConnectionFactory(connFact,connPool,null,null,false,true);
    }
    catch (Exception ex) {
      throw new SQLException(ex.getMessage());
    }
View Full Code Here

      /*
       * Puts pool-specific wrappers on factory connections. For clarification: "[PoolableConnection]Factory," not
       * "Poolable[ConnectionFactory]."
       */
      PoolableConnectionFactory pcf = new PoolableConnectionFactory( factory, // ConnectionFactory
          pool, // ObjectPool
          kopf, // KeyedObjectPoolFactory
          validQuery, // String (validation query)
          defaultReadOnly, // boolean (default to read-only?)
          defaultAutoCommit // boolean (default to auto-commit statements?)
          );

      if ( attributes.containsKey( IDBDatasourceService.DEFAULT_TRANSACTION_ISOLATION )
          && !IDBDatasourceService.TRANSACTION_ISOLATION_NONE_VALUE.equalsIgnoreCase( attributes
              .get( IDBDatasourceService.DEFAULT_TRANSACTION_ISOLATION ) ) ) {
        Isolation isolationLevel =
            Isolation.valueOf( attributes.get( IDBDatasourceService.DEFAULT_TRANSACTION_ISOLATION ) );

        if ( isolationLevel != null ) {
          pcf.setDefaultTransactionIsolation( isolationLevel.value() );
        }
      }

      if ( attributes.containsKey( IDBDatasourceService.DEFAULT_CATALOG ) ) {
        pcf.setDefaultCatalog( attributes.get( IDBDatasourceService.DEFAULT_CATALOG ) );
      }

      /*
       * initialize the pool to X connections
       */
 
View Full Code Here

            pool.setMinIdle(minSize);
            pool.setMaxWait(120000);


            // create the pool object factory
            PoolableConnectionFactory factory = new PoolableConnectionFactory(xacf, pool, null, null, true, true);
            factory.setValidationQuery("select example_type_id from example_type limit 1");
            factory.setDefaultReadOnly(false);

            String transIso = jotmJdbcElement.getAttribute("isolation-level");
            if (transIso != null && transIso.length() > 0) {
                if ("Serializable".equals(transIso)) {
                    factory.setDefaultTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
                } else if ("RepeatableRead".equals(transIso)) {
                    factory.setDefaultTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
                } else if ("ReadUncommitted".equals(transIso)) {
                    factory.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
                } else if ("ReadCommitted".equals(transIso)) {
                    factory.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
                } else if ("None".equals(transIso)) {
                    factory.setDefaultTransactionIsolation(Connection.TRANSACTION_NONE);
                }
            }
            pool.setFactory(factory);

            mds = new ManagedDataSource(pool, xacf.getTransactionRegistry());
View Full Code Here

    @Test
    public void testOperationCollection() throws SQLException {
        DataSourceConnectionFactory connFactory = new DataSourceConnectionFactory(dataSource);
        ObjectPool connPool = new GenericObjectPool();
        PoolableConnectionFactory poolFactory = new PoolableConnectionFactory(connFactory, connPool, null, null, false, true);
        PoolingDataSource poolDs = new PoolingDataSource(poolFactory.getPool());
        String sql = "select * from appointment where owner = 'Agim'";
        Connection c = poolDs.getConnection();
        try {
            PreparedStatement ps = c.prepareStatement(sql);
            try {
View Full Code Here

              statementFactoryConfig.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;
 
              statementFactory = new GenericKeyedObjectPoolFactory(null,statementFactoryConfig);
            }
           
            PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(
                    connectionFactory, connectionPool, statementFactory,
                    validationQuery, // validation query
                    false, // read only is not default for now
                    false); // Autocommit defaults to none
View Full Code Here

                );
   
    ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(
        connectURI, username, password);

    PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(
        connectionFactory, connectionPool, null, null, false, true);

    PoolingDataSource dataSource = new PoolingDataSource(connectionPool);

    return dataSource;
View Full Code Here

TOP

Related Classes of org.apache.commons.dbcp.PoolableConnectionFactory

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.