Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.quartz.utils
Class PoolingConnectionProvider

    java.lang.Object
      org.quartz.utils.PoolingConnectionProvider

All Implemented Interfaces:
  ConnectionProvider

    public class PoolingConnectionProvider

extends Object
implements ConnectionProvider

A `ConnectionProvider` implementation that creates its own pool of connections.

This class uses C3PO (http://www.mchange.com/projects/c3p0/index.html) as the underlying pool implementation.

Author:
  Sharada Jambula, James House, Mohammad Rezaei
See Also:
  `DBConnectionManager`, `ConnectionProvider`

Field Summary
`static String` | `DB_DRIVER` The JDBC database driver.
`static String` | `DB_IDLE_VALIDATION_SECONDS` The number of seconds between tests of idle connections - only enabled if the validation query property is set.
`static String` | `DB_MAX_CACHED_STATEMENTS_PER_CONNECTION` The maximum number of prepared statements that will be cached per connection in the pool.
`static String` | `DB_MAX_CONNECTIONS` The maximum number of database connections to have in the pool.
`static String` | `DB_PASSWORD` The database user password.
`static String` | `DB_URL` The JDBC database URL.
`static String` | `DB_USER` The database user name.
`static String` | `DB_VALIDATE_ON_CHECKOUT` Whether the database sql query to validate connections should be executed every time a connection is retrieved from the pool to ensure that it is still valid.
`static String` | `DB_VALIDATION_QUERY` The database sql query to execute every time a connection is returned to the pool to ensure that it is still valid.
`static int` | `DEFAULT_DB_MAX_CACHED_STATEMENTS_PER_CONNECTION` Default maximum number of database connections in the pool.
`static int` | `DEFAULT_DB_MAX_CONNECTIONS` Default maximum number of database connections in the pool.

Constructor Summary
`PoolingConnectionProvider(Properties config)` Create a connection pool using the given properties.
`PoolingConnectionProvider(String dbDriver, String dbURL, String dbUser, String dbPassword, int maxConnections, String dbValidationQuery)`

Method Summary
`Connection` | `getConnection()`
`protected com.mchange.v2.c3p0.ComboPooledDataSource` | `getDataSource()` Get the C3PO ComboPooledDataSource created during initialization.
`void` | `initialize()`
`void` | `shutdown()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DB_DRIVER

    public static final String DB_DRIVER

  The JDBC database driver.

  See Also:
    Constant Field Values

### DB_URL

    public static final String DB_URL

  The JDBC database URL.

  See Also:
    Constant Field Values

### DB_USER

    public static final String DB_USER

  The database user name.

  See Also:
    Constant Field Values

### DB_PASSWORD

    public static final String DB_PASSWORD

  The database user password.

  See Also:
    Constant Field Values

### DB_MAX_CONNECTIONS

    public static final String DB_MAX_CONNECTIONS

  The maximum number of database connections to have in the pool. Default is 10.

  See Also:
    Constant Field Values

### DB_MAX_CACHED_STATEMENTS_PER_CONNECTION

    public static final String DB_MAX_CACHED_STATEMENTS_PER_CONNECTION

  The maximum number of prepared statements that will be cached per connection in the pool. Depending upon your JDBC Driver this may significantly help performance, or may slightly hinder performance. Default is 120, as Quartz uses over 100 unique statements. 0 disables the feature.

  See Also:
    Constant Field Values

### DB_VALIDATION_QUERY

    public static final String DB_VALIDATION_QUERY

  The database sql query to execute every time a connection is returned to the pool to ensure that it is still valid.

  See Also:
    Constant Field Values

### DB_IDLE_VALIDATION_SECONDS

    public static final String DB_IDLE_VALIDATION_SECONDS

  The number of seconds between tests of idle connections - only enabled if the validation query property is set. Default is 50 seconds.

  See Also:
    Constant Field Values

### DB_VALIDATE_ON_CHECKOUT

    public static final String DB_VALIDATE_ON_CHECKOUT

  Whether the database sql query to validate connections should be executed every time a connection is retrieved from the pool to ensure that it is still valid. If false, then validation will occur on check-in. Default is false.

  See Also:
    Constant Field Values

### DEFAULT_DB_MAX_CONNECTIONS

    public static final int DEFAULT_DB_MAX_CONNECTIONS

  Default maximum number of database connections in the pool.

  See Also:
    Constant Field Values

### DEFAULT_DB_MAX_CACHED_STATEMENTS_PER_CONNECTION

    public static final int DEFAULT_DB_MAX_CACHED_STATEMENTS_PER_CONNECTION

  Default maximum number of database connections in the pool.

  See Also:
    Constant Field Values

Constructor Detail

### PoolingConnectionProvider

    public PoolingConnectionProvider(String dbDriver,
                                     String dbURL,
                                     String dbUser,
                                     String dbPassword,
                                     int maxConnections,
                                     String dbValidationQuery)
                              throws SQLException,
                                     SchedulerException

Throws:
  `SQLException`
  `SchedulerException`

### PoolingConnectionProvider

    public PoolingConnectionProvider(Properties config)
                              throws SchedulerException,
                                     SQLException

  Create a connection pool using the given properties.

  The properties passed should contain:

  - `DB_DRIVER`- The database driver class name
  - `DB_URL`- The database URL
  - `DB_USER`- The database user
  - `DB_PASSWORD`- The database password
  - `DB_MAX_CONNECTIONS`- The maximum # connections in the pool, optional
  - `DB_VALIDATION_QUERY`- The sql validation query, optional

  Parameters:
    `config` - configuration properties
  Throws:
    `SchedulerException`
    `SQLException`

Method Detail

### getDataSource

    protected com.mchange.v2.c3p0.ComboPooledDataSource getDataSource()

  Get the C3PO ComboPooledDataSource created during initialization.

  This can be used to set additional data source properties in a subclass's constructor.

### getConnection

    public Connection getConnection()
                             throws SQLException

  Specified by:
    `getConnection` in interface `ConnectionProvider`
  Returns:
    connection managed by this provider
  Throws:
    `SQLException`

### shutdown

    public void shutdown()
                  throws SQLException

  Specified by:
    `shutdown` in interface `ConnectionProvider`
  Throws:
    `SQLException`

### initialize

    public void initialize()
                    throws SQLException

  Specified by:
    `initialize` in interface `ConnectionProvider`
  Throws:
    `SQLException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2001-2013, Terracotta, Inc.