org.quartz.utils
Class PoolingConnectionProvider

java.lang.Object
  extended by org.quartz.utils.PoolingConnectionProvider
All Implemented Interfaces:
ConnectionProvider

public class PoolingConnectionProvider
extends java.lang.Object
implements ConnectionProvider

A ConnectionProvider implementation that creates its own pool of connections.

This class uses DBCP, an Apache-Jakarta-Commons product.

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

Field Summary
static java.lang.String DB_DRIVER
          The JDBC database driver.
static java.lang.String DB_MAX_CONNECTIONS
          The maximum number of database connections to have in the pool.
static java.lang.String DB_PASSWORD
          The database user password.
static java.lang.String DB_URL
          The JDBC database URL.
static java.lang.String DB_USER
          The database user name.
static java.lang.String DB_VALIDATION_QUERY
          The database sql query to execute everytime a connection is retrieved from the pool to ensure that it is still valid.
static int DEFAULT_DB_MAX_CONNECTIONS
          Default maximum number of database connections in the pool.
 
Constructor Summary
PoolingConnectionProvider(java.util.Properties config)
          Create a connection pool using the given properties.
PoolingConnectionProvider(java.lang.String dbDriver, java.lang.String dbURL, java.lang.String dbUser, java.lang.String dbPassword, int maxConnections, java.lang.String dbValidationQuery)
           
 
Method Summary
 java.sql.Connection getConnection()
           
protected  org.apache.commons.dbcp.BasicDataSource getDataSource()
          Get the DBCP BasicDataSource created during initialization.
 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 java.lang.String DB_DRIVER
The JDBC database driver.

See Also:
Constant Field Values

DB_URL

public static final java.lang.String DB_URL
The JDBC database URL.

See Also:
Constant Field Values

DB_USER

public static final java.lang.String DB_USER
The database user name.

See Also:
Constant Field Values

DB_PASSWORD

public static final java.lang.String DB_PASSWORD
The database user password.

See Also:
Constant Field Values

DB_MAX_CONNECTIONS

public static final java.lang.String DB_MAX_CONNECTIONS
The maximum number of database connections to have in the pool.

See Also:
Constant Field Values

DB_VALIDATION_QUERY

public static final java.lang.String DB_VALIDATION_QUERY
The database sql query to execute everytime a connection is retrieved from the pool to ensure that it is still valid.

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
Constructor Detail

PoolingConnectionProvider

public PoolingConnectionProvider(java.lang.String dbDriver,
                                 java.lang.String dbURL,
                                 java.lang.String dbUser,
                                 java.lang.String dbPassword,
                                 int maxConnections,
                                 java.lang.String dbValidationQuery)
                          throws java.sql.SQLException
Throws:
java.sql.SQLException

PoolingConnectionProvider

public PoolingConnectionProvider(java.util.Properties config)
                          throws java.sql.SQLException
Create a connection pool using the given properties.

The properties passed should contain:

Parameters:
config - configuration properties
Throws:
java.sql.SQLException
Method Detail

getDataSource

protected org.apache.commons.dbcp.BasicDataSource getDataSource()
Get the DBCP BasicDataSource created during initialization.

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


getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Specified by:
getConnection in interface ConnectionProvider
Returns:
connection managed by this provider
Throws:
java.sql.SQLException

shutdown

public void shutdown()
              throws java.sql.SQLException
Specified by:
shutdown in interface ConnectionProvider
Throws:
java.sql.SQLException


Copyright 2001-2019, Terracotta, Inc.