Package org.apache.commons.dbcp

Examples of org.apache.commons.dbcp.ConnectionFactory


                                  String user,
                                  String password) {
    GenericObjectPool connectionPool = new GenericObjectPool();
    connectionPool.setMaxActive(256);
    connectionPool.setMaxIdle(256);
    ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(
        uri, user, password);
    //
    // This constructor modifies the connection pool, setting its connection
    // factory to this.  (So despite how it may appear, all of the objects
    // declared in this method are incorporated into the returned result.)
View Full Code Here


     * exists so subclasses can replace the implementation class.
     */
    @Override
    protected ConnectionFactory createConnectionFactory() throws SQLException {
      if (useDriverManager) {
        return new ConnectionFactory() {
          @Override
          public Connection createConnection() throws SQLException {
            return DriverManager.getConnection(getUrl(), getUsername(), getPassword());
          }
        };
      } else {
        return new ConnectionFactory() {
          @Override
          public Connection createConnection() throws SQLException {
            Driver driver;

            try {
View Full Code Here

    // We'll use the DriverManagerConnectionFactory,
    // using the connect string passed in the command line
    // arguments.
    //
    //ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectURI,null);
    ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(url, "admin_user", "client00");

    //
    // Now we'll create the PoolableConnectionFactory, which wraps
    // the "real" Connections created by the ConnectionFactory with
    // the classes that implement the pooling functionality.
View Full Code Here

      url = "jdbc:mckoi://localhost";
    } else {
      url = "jdbc:mckoi:local://resource/nz.co.transparent.client.db.conf";
    }

    ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(url, "admin_user", "client00");
    //
    // Now we'll create the PoolableConnectionFactory, which wraps
    // the "real" Connections created by the ConnectionFactory with
    // the classes that implement the pooling functionality.
    //
View Full Code Here

    // We'll use the DriverManagerConnectionFactory,
    // using the connect string passed in the command line
    // arguments.
    //
    //ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectURI,null);
    ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectURI, "admin_user", "client00");

    //
    // Now we'll create the PoolableConnectionFactory, which wraps
    // the "real" Connections created by the ConnectionFactory with
    // the classes that implement the pooling functionality.
View Full Code Here

 
  public ConnectionPoolDataSource(DataSource underlyingDataSource) {
    if (underlyingDataSource == null) {
      throw new IllegalArgumentException("underlyingDataSource is null");
    }
    ConnectionFactory connectionFactory = new ConfiguringConnectionFactory(underlyingDataSource);
    GenericObjectPool objectPool = new GenericObjectPool();
    objectPool.setTestOnBorrow(false);
    objectPool.setTestOnReturn(false);
    objectPool.setTestWhileIdle(true);
    objectPool.setTimeBetweenEvictionRunsMillis(60 * 1000L);
 
View Full Code Here

                throw e;
            }
           
            ObjectPool connectionPool = new GenericObjectPool(null, maxActive, whenExhausted, maxWait);
           
            ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectURI, user, password);
           
            dsConnectionFactory = new PoolableConnectionFactory(connectionFactory, connectionPool, null, null, false, true);
           
            dataSource = new PoolingDataSource(connectionPool);           
           
View Full Code Here

            Properties cfProps = new Properties();
            cfProps.put("user", jdbcUsername);
            cfProps.put("password", jdbcPassword);

            // create the connection factory
            ConnectionFactory cf = new DriverConnectionFactory(jdbcDriver, jdbcUri, cfProps);

            // wrap it with a LocalXAConnectionFactory
            XAConnectionFactory xacf = new LocalXAConnectionFactory(txMgr, cf);

            // configure the pool settings
View Full Code Here

                return xaConnectionFactory;

            } else {

                // If xa data source is not specified a DriverConnectionFactory is created and wrapped with a LocalXAConnectionFactory
                ConnectionFactory connectionFactory = new DataSourceConnectionFactory(dataSource, username, password);
                XAConnectionFactory xaConnectionFactory = new LocalXAConnectionFactory(getTransactionManager(), connectionFactory);
                setTransactionRegistry(xaConnectionFactory.getTransactionRegistry());
                return xaConnectionFactory;
            }
        }
View Full Code Here

      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]."
      */
 
View Full Code Here

TOP

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

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.