atg.service.jdbc
Class MonitoredDataSource

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.service.resourcepool.ResourcePool
              extended by atg.service.jdbc.MonitoredDataSource
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, atg.service.jdbc.DataSourceShutdownSender, ConnectionStats, atg.service.resourcepool.ResourcePoolResourceKeys, java.sql.Wrapper, java.util.EventListener, javax.sql.CommonDataSource, javax.sql.ConnectionEventListener, javax.sql.DataSource

public class MonitoredDataSource
extends ResourcePool
implements javax.sql.DataSource, javax.sql.ConnectionEventListener, ConnectionStats, atg.service.jdbc.DataSourceShutdownSender

A DataSource that pools connections that participate in Java Transactions.

As a child of the ResourcePool class, this DataSource inherits all of that class's resource creation and pooling features. However, the inherited checkout/checkIn methods should never be used. Connections should be obtained from the pool via the DataSource.getConnection() method and returned to the pool by calling Connection.close(). Whereas in previous implentations of a Connection pool it was imperative to never call close on the pooled Connection, use of this implementation requires Connection.close() to be called. Calling Connection.close() does not actually close the Connection. Instead, this is the method defined in the J2EE JDBC extensions for returning pooled Connections to the Connection pool.

This DataSource is designed to only work on top of an XADataSource. Therefore, when used within the scope of a distributed transaction commit(), rollback(), and setAutoCommit() should never be called on Connections obtained from it. Those functions are executed by the TransactionManager. When used in local transaction mode, i.e. outside the scope of a distributed transaction, all of the Connections transactional methods are available for use.

Typical usage of this DataSource might look as follows:

   DataSource ds = ;
   Connection c = null;
   try {
     try {
       c = ds.getConnection();
       // Various work without calling c.commit() or c.rollback().
     } finally {
       // Closing of the Connection must always occur or else
       // Connections will not be returned to the pool properly!
       if (c != null)
         c.close();
     }
   } catch (SQLException sqle) {
     // If something went wrong, we might want to rollback
     // the transaction.
   }
 
Note this example assumes a distributed transaction is in place meaning transactioning is handled by JTA and no transactioning methods are called on the Connection itself.

All Connections produced by this DataSource are MonitoredConnections, i.e. they are normal Connections wrapped for the purpose of gathering statistics. Because of this, message logging is achievable at a finer granularity. The standard ApplicationLogging interface exists for messages generated by the DataSource proper and a variant of the interface is implemented for the logging of messages generated by Connections. Use the methods loggingSQLInfo(), loggingSQLDebug(), loggingSQLWarning(), and loggingSQLError() to turn off message logging for Connections created by this DataSource.


Nested Class Summary
 class MonitoredDataSource.SQLLogging
          A utility class which builds a separate logging interface for SQL logging to have access to.
 
Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.service.resourcepool.ResourcePool
mBlocking, mCheckoutBlockTime, mCreatingResources, mCreationTimeLimit, mFreeResources, mHealthy, mMax, mMaxFree, mMaxPendingCreations, mMaxStartupAttempts, mMin, mPool, mResourceClassName, mStartupSleepTime, mUnusedPoolSlots
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.service.resourcepool.ResourcePoolResourceKeys
RESOURCE_BUNDLE, RSRC_blockTimeout, RSRC_ciCreateFailure, RSRC_ciForeignResource, RSRC_ciWrongResource, RSRC_coNonRunning, RSRC_creationLimit, RSRC_creationTimeout, RSRC_failedInitialPopulation, RSRC_hitPoolMax, RSRC_maxResourcePerThread, RSRC_maxThreads, RSRC_misconfiguration, RSRC_nestedCheckout, RSRC_nonOwningThread, RSRC_notImplemented, RSRC_poolDisabled, RSRC_startupFailure, RSRC_usingClosedConnection
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
MonitoredDataSource()
          Constructs an uninitialized MonitoredDataSource.
 
Method Summary
protected  void addAdminInfo(javax.servlet.http.HttpServletRequest pRequest, javax.servlet.http.HttpServletResponse pResponse, javax.servlet.ServletOutputStream pOut)
          Adds to the HTML Admin response any information specific to the the ResourcePool subclass.
 void addDataSourceShutdownListener(atg.service.jdbc.DataSourceShutdownListener pListener)
          Adds the given listener to the shutdown sender's list of listeners.
 void checkIn(ResourceObject pResource)
          Though this class extends ResourcePool, it is not meant to be used as a ResourcePool is used.
 ResourceObject checkOut(java.lang.String pCheckOutTag)
          Though this class extends ResourcePool, it is not meant to be used as a ResourcePool is used.
protected  void ci(ResourceObject pResource)
          Checks a resource into the pool.
protected  ResourceObject co(java.lang.String pCheckOutTag)
          The internal resource checkout method.
 void connectionClosed(javax.sql.ConnectionEvent pEvent)
          Invoked when the application calls close() on its representation of the connection.
 void connectionErrorOccurred(javax.sql.ConnectionEvent pEvent)
          Invoked when a fatal connection error occurs, just before an SQLException is thrown to the application.
 java.lang.Object createResource()
          Creates a new XAConnection for use by the pool.
 void destroyResource(java.lang.Object pResource)
          Destroys the once pooled resource.
 void doStartService()
          Things to do when the service starts up.
 void doStopService()
          Things to do when the service is stopped.
 int getCommitCount()
          Returns the number of times commit() has been called
 java.sql.Connection getConnection()
          Returns a Connection that is participating in the current Transaction.
 java.sql.Connection getConnection(java.lang.String pUsername, java.lang.String pPassword)
          This method is unsupported in this implementation.
 int getCreateStatementCount()
          Returns the number of times createStatement() has been called
 javax.sql.XADataSource getDataSource()
          Returns property dataSource.
 java.lang.String getDataSourceConnectionInfo()
          Return the connection information String for our DataSource.
 atg.service.jdbc.DataSourceInfoCache getDataSourceInfoCache()
          Returns property dataSourceInfoCache
 java.util.Properties getDataSourceJNDIEnvironment()
          Returns property dataSourceJNDIEnvironment.
 java.lang.String getDataSourceJNDIName()
          Returns property dataSourceJNDIName.
 int getErrorCount()
          Returns the number of times a SQLException resulted from calls.
 int getExecuteCount()
          Returns the number of times Statement.execute() has been called
 int getExecuteQueryCount()
          Returns the number of times Statement.executeQuery() has been called
 int getExecuteUpdateCount()
          Returns the number of times Statement.executeUpdate() has been called
 int getGetMoreResultsCount()
          Returns the number of times Statement.getMoreResults() has been called
 java.lang.String[] getInitializingSQL()
          Returns property initializingSQL.
 int getLoginTimeout()
          Returns property loginTimeout.
 java.io.PrintWriter getLogWriter()
          This property from the DataSource interface is ignored.
 java.lang.Integer getMaxFieldSize()
          Returns the size of the data that can be returned for any column.
 java.lang.Integer getMaxRows()
          Returns the maximum number of rows that can be returned for any query.
 int getPrepareCallCount()
          Returns the number of times prepareCall() has been called
 int getPrepareStatementCount()
          Returns the number of times prepareStatement() has been called
 java.lang.Integer getQueryTimeout()
          Returns the maximum number of seconds that the driver will wait for a Statement to execute.
 int getResultSetRowCount()
          Returns the number of times ResultSet.next() has been called
 int getRollbackCount()
          Returns the number of times rollback() has been called
 javax.transaction.TransactionManager getTransactionManager()
          Returns property transactionManager.
 void incrementCommitCount()
          Increments the number of times commit() has been called
 void incrementCreateStatementCount()
          Increments the number of times createStatement() has been called
 void incrementErrorCount()
          Increments the number of times a SQLException resulted from calls.
 void incrementExecuteCount()
          Increments the number of times Statement.execute() has been called
 void incrementExecuteQueryCount()
          Increments the number of times Statement.executeQuery() has been called
 void incrementExecuteUpdateCount()
          Increments the number of times Statement.executeUpdate() has been called
 void incrementGetMoreResultsCount()
          Increments the number of times Statement.getMoreResults() has been called
 void incrementPrepareCallCount()
          Increments the number of times prepareCall() has been called
 void incrementPrepareStatementCount()
          Increments the number of times prepareStatement() has been called
 void incrementResultSetRowCount()
          Increments the number of times ResultSet.next() has been called
 void incrementRollbackCount()
          Increments the number of times rollback() has been called
 boolean isDebugActiveQuery()
          Returns property debugActiveQuery.
 boolean isDisableDataSourceInfo()
          Whether to disable providing the datasource info property (presumably for security reasons).
 boolean isEnlistBeforeGet()
          Returns property enlistBeforeGet.
 boolean isLogDebugStacktrace()
          Returns property logDebugStacktrace.
 boolean isLoggingSQLDebug()
          This method returns whether or not an debug log event should be broadcast for MonitoredConnections.
 boolean isLoggingSQLError()
          This method returns whether or not an error log event should be broadcast for MonitoredConnections.
 boolean isLoggingSQLInfo()
          This method returns whether or not an info log event should be broadcast for MonitoredConnections.
 boolean isLoggingSQLWarning()
          This method returns whether or not an warning log event should be broadcast for MonitoredConnections.
 boolean isWrapperFor(java.lang.Class<?> pInterface)
          Returns true if this class implements the pInterface argument
protected  void reclaimResource(ResourceObject pRobj)
          Reclaims a resource that is most likely out of the pool.
 void removeDataSourceShutdownListener(atg.service.jdbc.DataSourceShutdownListener pListener)
          Removes the given listener from the shutdown sender's list of shutdown listeners.
 void setDataSource(javax.sql.XADataSource pXADataSource)
          Sets the property dataSource.
 void setDataSourceInfoCache(atg.service.jdbc.DataSourceInfoCache pDataSourceInfoCache)
          Sets the data source info cache, which is used to extract human readable information.
 void setDataSourceJNDIEnvironment(java.util.Properties pDataSourceJNDIEnvironment)
          Sets property dataSourceJNDIEnvironment.
 void setDataSourceJNDIName(java.lang.String pDataSourceJNDIName)
          Sets property dataSourceJNDIName.
 void setDebugActiveQuery(boolean pDebugActiveQuery)
          Sets property debugActiveQuery.
 void setDisableDataSourceInfo(boolean pDisableDataSourceInfo)
          Set whether to disable providing the datasource info property (presumably for security reasons).
 void setEnlistBeforeGet(boolean pEnlistBeforeGet)
          Sets property enlistBeforeGet.
 void setInitializingSQL(java.lang.String[] pInitializingSQL)
          Sets property initializingSQL.
 void setLogDebugStacktrace(boolean pLogDebugStacktrace)
          Sets property logDebugStacktrace.
 void setLoggingSQLDebug(boolean pLogging)
          Sets whether or not error log events should be logged for MonitoredConnections.
 void setLoggingSQLError(boolean pLogging)
          Sets whether or not error log events should be logged for MonitoredConnections.
 void setLoggingSQLInfo(boolean pLogging)
          Sets whether or not info log events should be logged for MonitoredConnections.
 void setLoggingSQLWarning(boolean pLogging)
          Sets whether or not warning log events should be logged for MonitoredConnections.
 void setLoginTimeout(int pLoginTimeout)
          Sets property loginTimeout.
 void setLogWriter(java.io.PrintWriter pLogWriter)
          This property from the DataSource interface is ignored.
 void setMaxFieldSize(java.lang.Integer pMaxFieldSize)
          Sets the size of the data that can be returned for any column.
 void setMaxRows(java.lang.Integer pMaxRows)
          Sets the maximum number of rows that can be returned for any query.
 void setQueryTimeout(java.lang.Integer pQueryTimeout)
          Sets the maximum number of seconds that the driver will wait for a Statement to execute.
 void setTransactionManager(javax.transaction.TransactionManager pValue)
           
<T> T
unwrap(java.lang.Class<T> pInterface)
          Returns an object that implements the given interface
 boolean verifyResourceValidity(ResourceObject pRobj)
          In the non-J2EE world, connections were verified by seeing if they had been closed by someone.
 
Methods inherited from class atg.service.resourcepool.ResourcePool
block, createAdminServlet, finalize, getAverageResourceCreationTime, getBlocking, getCheckoutBlockTime, getCreationTimeLimit, getCurrentStack, getDebugConnections, getLastError, getMax, getMaxConcurrentResourcesPerThread, getMaxConcurrentThreads, getMaxFree, getMaxIdleAge, getMaxPendingCreations, getMaxResourceAge, getMaxResourcesPerThread, getMaxSimultaneousResourcesOut, getMaxThreadsWithResourcesOut, getMin, getNumCheckedOutResources, getNumFreeResources, getNumTotalResources, getResourceClassName, getStartupAttempts, getStartupFailureSleepTime, invalidateAllResources, isEnabled, isWarnOnNestedCheckouts, populateSlot, pruneFreeResources, resetMaxConcurrentResourcesPerThread, resetMaxConcurrentThreads, resetMaxSimultaneousResourcesOut, setBlocking, setCheckoutBlockTime, setCreationTimeLimit, setDebugConnections, setLastError, setMax, setMaxFree, setMaxIdleAge, setMaxPendingCreations, setMaxResourceAge, setMaxResourcesPerThread, setMaxThreadsWithResourcesOut, setMin, setResourceClassName, setStartupAttempts, setStartupFailureSleepTime, setWarnOnNestedCheckouts, unblock
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

MonitoredDataSource

public MonitoredDataSource()
Constructs an uninitialized MonitoredDataSource.

Method Detail

setDataSourceJNDIName

public void setDataSourceJNDIName(java.lang.String pDataSourceJNDIName)
Sets property dataSourceJNDIName.
JNDI name of the XADataSource to get Connections from.

Parameters:
pDataSourceJNDIName - new value to set

getDataSourceJNDIName

public java.lang.String getDataSourceJNDIName()
Returns property dataSourceJNDIName.
JNDI name of the XADataSource to get Connections from.

Returns:
String

setDataSourceJNDIEnvironment

public void setDataSourceJNDIEnvironment(java.util.Properties pDataSourceJNDIEnvironment)
Sets property dataSourceJNDIEnvironment.
An optional set of properties needed by JNDI to resolve the DataSource.

Parameters:
pDataSourceJNDIEnvironment - new value to set

getDataSourceJNDIEnvironment

public java.util.Properties getDataSourceJNDIEnvironment()
Returns property dataSourceJNDIEnvironment.
An optional set of properties needed by JNDI to resolve the DataSource.

Returns:
Properties

setDataSource

public void setDataSource(javax.sql.XADataSource pXADataSource)
Sets the property dataSource.
The XADataSource to get new Connections for the pool from. This method is used to set the property directly. Alternatively, the properties dataSourceJNDIName and dataSourceJNDIEnvironment can be used.

Parameters:
pXADataSource - new value to set

getDataSource

public javax.sql.XADataSource getDataSource()
Returns property dataSource.
The XADataSource to get new Connections for the pool from. This property is either the DataSource set via the setDataSource() method or resolved via JNDI from the setDataSourceJNDIName property.

Returns:
XADataSource

setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pValue)

getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
Returns property transactionManager.
The TransactionManager handling distributed transactions.

Returns:
TransactionManager

isLoggingSQLInfo

public boolean isLoggingSQLInfo()
This method returns whether or not an info log event should be broadcast for MonitoredConnections.

Returns:
boolean true if info log events should be logged
false if info log events should not be logged

setLoggingSQLInfo

public void setLoggingSQLInfo(boolean pLogging)
Sets whether or not info log events should be logged for MonitoredConnections.


isLoggingSQLWarning

public boolean isLoggingSQLWarning()
This method returns whether or not an warning log event should be broadcast for MonitoredConnections.

Returns:
boolean true if warning log events should be logged
false if warning log events should not be logged

setLoggingSQLWarning

public void setLoggingSQLWarning(boolean pLogging)
Sets whether or not warning log events should be logged for MonitoredConnections.


isLoggingSQLError

public boolean isLoggingSQLError()
This method returns whether or not an error log event should be broadcast for MonitoredConnections.

Returns:
boolean true if error log events should be logged
false if error log events should not be logged

setLoggingSQLError

public void setLoggingSQLError(boolean pLogging)
Sets whether or not error log events should be logged for MonitoredConnections.


isLoggingSQLDebug

public boolean isLoggingSQLDebug()
This method returns whether or not an debug log event should be broadcast for MonitoredConnections.

Returns:
boolean true if debug log events should be logged
false if debug log events should not be logged

setLoggingSQLDebug

public void setLoggingSQLDebug(boolean pLogging)
Sets whether or not error log events should be logged for MonitoredConnections.


getMaxFieldSize

public java.lang.Integer getMaxFieldSize()
Returns the size of the data that can be returned for any column. Passed to every MonitoredConnection for use with MonitoredStatements


setMaxFieldSize

public void setMaxFieldSize(java.lang.Integer pMaxFieldSize)
Sets the size of the data that can be returned for any column. Setting this to a -1 value is equivalent to disabling it.


getMaxRows

public java.lang.Integer getMaxRows()
Returns the maximum number of rows that can be returned for any query. Passed to every MonitoredConnection for use with MonitoredStatements


setMaxRows

public void setMaxRows(java.lang.Integer pMaxRows)
Sets the maximum number of rows that can be returned for any query.


getQueryTimeout

public java.lang.Integer getQueryTimeout()
Returns the maximum number of seconds that the driver will wait for a Statement to execute. Passed to every MonitoredConnection for use with MonitoredStatements


setQueryTimeout

public void setQueryTimeout(java.lang.Integer pQueryTimeout)
Sets the maximum number of seconds that the driver will wait for a Statement to execute.


setInitializingSQL

public void setInitializingSQL(java.lang.String[] pInitializingSQL)
Sets property initializingSQL.
An array of SQL commands to be executed on newly created Connections before inserted into the pool.

Parameters:
pInitializingSQL - new value to set

getInitializingSQL

public java.lang.String[] getInitializingSQL()
Returns property initializingSQL.
An array of SQL commands to be executed on newly created Connections before inserted into the pool.

Returns:
String[]

setEnlistBeforeGet

public void setEnlistBeforeGet(boolean pEnlistBeforeGet)
Sets property enlistBeforeGet.
Do resource enlistment before calling getConnection() on XAConnection. Unfortunately JDBC has a loose specification allowing vendors to do things differently from each other. This property addresses such a problem. Some drivers do not allow you to call XAConnection.getConnection() before enlisting the connection's XAResource with the TransactionManager. Some drivers do not allow the exact opposite. The default for this property accommodates Oracle and Sybase. Set this property to true for Merant drivers.

Parameters:
pEnlistBeforeGet - new value to set

isEnlistBeforeGet

public boolean isEnlistBeforeGet()
Returns property enlistBeforeGet.
Do resource enlistment before calling getConnection() on XAConnection. Unfortunately JDBC has a loose specification allowing vendors to do things differently from each other. This property addresses such a problem. Some drivers do not allow you to call XAConnection.getConnection() before enlisting the connection's XAResource with the TransactionManager. Some drivers do not allow the exact opposite. The default for this property accommodates Oracle and Sybase. Set this property to true for Merant drivers.

Returns:
boolean

setLogDebugStacktrace

public void setLogDebugStacktrace(boolean pLogDebugStacktrace)
Sets property logDebugStacktrace.
Include a stacktrace with the logDebug message logged on checkout. Useful for tracking down code that uses connections.

Parameters:
pLogDebugStacktrace - new value to set

isLogDebugStacktrace

public boolean isLogDebugStacktrace()
Returns property logDebugStacktrace.
Include a stacktrace with the logDebug message logged on checkout. Useful for tracking down code that uses connections.

Returns:
boolean

setDebugActiveQuery

public void setDebugActiveQuery(boolean pDebugActiveQuery)
Sets property debugActiveQuery.
Whether or not to store stacktraces and SQL queries for display in the HTML Admin.

This should not be used except when debugging as more overhead will be generated from this feature.

Parameters:
pDebugActiveQuery - new value to set

isDebugActiveQuery

public boolean isDebugActiveQuery()
Returns property debugActiveQuery.
Whether or not to store stacktraces and SQL queries for display in the HTML Admin.

This should not be used except when debugging as more overhead will be generated from this feature.

Returns:
boolean

setLoginTimeout

public void setLoginTimeout(int pLoginTimeout)
Sets property loginTimeout.
The maximum time in seconds to wait attempting to connect to a database. This DataSource property has been translated into ResourcePool.checkoutBlockTime. Setting loginTimeout will be the same as setting ResourcePool.checkoutBlockTime.

Specified by:
setLoginTimeout in interface javax.sql.CommonDataSource
Parameters:
pLoginTimeout - new value to set

getLoginTimeout

public int getLoginTimeout()
Returns property loginTimeout.
The maximum time in seconds to wait attempting to connect to a database. This DataSource property has been translated into ResourcePool.checkoutBlockTime. Setting loginTimeout will be the same as setting ResourcePool.checkoutBlockTime.

Specified by:
getLoginTimeout in interface javax.sql.CommonDataSource
Returns:
int

setLogWriter

public void setLogWriter(java.io.PrintWriter pLogWriter)
This property from the DataSource interface is ignored. All of the pool and objects generated by the pool write log messages to the ApplicationLogging interfaces.

Specified by:
setLogWriter in interface javax.sql.CommonDataSource

getLogWriter

public java.io.PrintWriter getLogWriter()
This property from the DataSource interface is ignored. All of the pool and objects generated by the pool write log messages to the ApplicationLogging interfaces.

Specified by:
getLogWriter in interface javax.sql.CommonDataSource

setDataSourceInfoCache

public void setDataSourceInfoCache(atg.service.jdbc.DataSourceInfoCache pDataSourceInfoCache)
Sets the data source info cache, which is used to extract human readable information.


getDataSourceInfoCache

public atg.service.jdbc.DataSourceInfoCache getDataSourceInfoCache()
Returns property dataSourceInfoCache


setDisableDataSourceInfo

public void setDisableDataSourceInfo(boolean pDisableDataSourceInfo)
Set whether to disable providing the datasource info property (presumably for security reasons).


isDisableDataSourceInfo

public boolean isDisableDataSourceInfo()
Whether to disable providing the datasource info property (presumably for security reasons).


getDataSourceConnectionInfo

public java.lang.String getDataSourceConnectionInfo()
Return the connection information String for our DataSource. It returns a string of the form "url" or "user@url" where "user" is the JDBC user (when available), and "url" is the JDBC connection URL.


doStartService

public void doStartService()
                    throws ServiceException
Things to do when the service starts up.

Overrides:
doStartService in class ResourcePool
Throws:
ServiceException - if an error occurred during the operation

doStopService

public void doStopService()
                   throws ServiceException
Things to do when the service is stopped.

Overrides:
doStopService in class ResourcePool
Throws:
ServiceException - if an error occurred during the operation

createResource

public java.lang.Object createResource()
                                throws ResourcePoolException
Creates a new XAConnection for use by the pool.

Overrides:
createResource in class ResourcePool
Returns:
Object on success
Throws:
ResourcePoolException - if there was a problem creating the XAConnection

destroyResource

public void destroyResource(java.lang.Object pResource)
Destroys the once pooled resource. This gets called when a resource has been marked as invalid. Here we clean up any resource wrapping, connection closing, and other tasks that should be performed before the resource is dropped for eventual garbage collection.

Overrides:
destroyResource in class ResourcePool
Parameters:
pResource - the Object to destroy

verifyResourceValidity

public boolean verifyResourceValidity(ResourceObject pRobj)
In the non-J2EE world, connections were verified by seeing if they had been closed by someone. Sadly, that interface is no longer available to us here in this method. All this method can do is check the ResourceObject's validity flag. Kind of a waste of what this method was intended for.

Overrides:
verifyResourceValidity in class ResourcePool
Parameters:
pResource - the ResourceObject to verify
Returns:
boolean true if the resource is still usable
false if the resource is not usable

checkOut

public ResourceObject checkOut(java.lang.String pCheckOutTag)
                        throws ResourcePoolException
Though this class extends ResourcePool, it is not meant to be used as a ResourcePool is used. This method should never be called as it will always throw an exception. Instead, getConnection() should be called for obtaining DB connections from the pool.

Overrides:
checkOut in class ResourcePool
Returns:
nothing as an exception is thrown instead
Throws:
ResourcePoolException - always thrown when called

checkIn

public void checkIn(ResourceObject pResource)
             throws ResourcePoolException
Though this class extends ResourcePool, it is not meant to be used as a ResourcePool is used. This method should never be called as it will always throw an exception. Instead, Connections will be automatically checked back into the pool when Connection.close() is called.

Overrides:
checkIn in class ResourcePool
Parameters:
pResource - a resource checked out from this pool
Throws:
ResourcePoolException - always thrown when called

getConnection

public java.sql.Connection getConnection(java.lang.String pUsername,
                                         java.lang.String pPassword)
                                  throws java.sql.SQLException
This method is unsupported in this implementation. Calling it will result in an UnsupportedOperationException;

Specified by:
getConnection in interface javax.sql.DataSource
Throws:
java.sql.SQLException

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Returns a Connection that is participating in the current Transaction.

Specified by:
getConnection in interface javax.sql.DataSource
Throws:
java.sql.SQLException

connectionClosed

public void connectionClosed(javax.sql.ConnectionEvent pEvent)
Invoked when the application calls close() on its representation of the connection.

Specified by:
connectionClosed in interface javax.sql.ConnectionEventListener
Parameters:
pEvent - an event object describing the source of the event

connectionErrorOccurred

public void connectionErrorOccurred(javax.sql.ConnectionEvent pEvent)
Invoked when a fatal connection error occurs, just before an SQLException is thrown to the application.

Specified by:
connectionErrorOccurred in interface javax.sql.ConnectionEventListener
Parameters:
pEvent - an event object describing the source of the event

addDataSourceShutdownListener

public void addDataSourceShutdownListener(atg.service.jdbc.DataSourceShutdownListener pListener)
Adds the given listener to the shutdown sender's list of listeners. The listener will be notified when the DataSource is shutting down.

Specified by:
addDataSourceShutdownListener in interface atg.service.jdbc.DataSourceShutdownSender
Parameters:
pListener - the listner wanting to know of shutdown events

removeDataSourceShutdownListener

public void removeDataSourceShutdownListener(atg.service.jdbc.DataSourceShutdownListener pListener)
Removes the given listener from the shutdown sender's list of shutdown listeners. The listener will no longer be notified when the DataSource is shutting down.

Specified by:
removeDataSourceShutdownListener in interface atg.service.jdbc.DataSourceShutdownSender
Parameters:
pListener - the listner wanting of the shutdown listener list

incrementErrorCount

public void incrementErrorCount()
Increments the number of times a SQLException resulted from calls.

Specified by:
incrementErrorCount in interface ConnectionStats

getErrorCount

public int getErrorCount()
Returns the number of times a SQLException resulted from calls.


incrementCommitCount

public void incrementCommitCount()
Increments the number of times commit() has been called

Specified by:
incrementCommitCount in interface ConnectionStats

getCommitCount

public int getCommitCount()
Returns the number of times commit() has been called


incrementRollbackCount

public void incrementRollbackCount()
Increments the number of times rollback() has been called

Specified by:
incrementRollbackCount in interface ConnectionStats

getRollbackCount

public int getRollbackCount()
Returns the number of times rollback() has been called


incrementCreateStatementCount

public void incrementCreateStatementCount()
Increments the number of times createStatement() has been called

Specified by:
incrementCreateStatementCount in interface ConnectionStats

getCreateStatementCount

public int getCreateStatementCount()
Returns the number of times createStatement() has been called


incrementPrepareStatementCount

public void incrementPrepareStatementCount()
Increments the number of times prepareStatement() has been called

Specified by:
incrementPrepareStatementCount in interface ConnectionStats

getPrepareStatementCount

public int getPrepareStatementCount()
Returns the number of times prepareStatement() has been called


incrementPrepareCallCount

public void incrementPrepareCallCount()
Increments the number of times prepareCall() has been called

Specified by:
incrementPrepareCallCount in interface ConnectionStats

getPrepareCallCount

public int getPrepareCallCount()
Returns the number of times prepareCall() has been called


incrementExecuteQueryCount

public void incrementExecuteQueryCount()
Increments the number of times Statement.executeQuery() has been called

Specified by:
incrementExecuteQueryCount in interface ConnectionStats

getExecuteQueryCount

public int getExecuteQueryCount()
Returns the number of times Statement.executeQuery() has been called


incrementExecuteUpdateCount

public void incrementExecuteUpdateCount()
Increments the number of times Statement.executeUpdate() has been called

Specified by:
incrementExecuteUpdateCount in interface ConnectionStats

getExecuteUpdateCount

public int getExecuteUpdateCount()
Returns the number of times Statement.executeUpdate() has been called


incrementExecuteCount

public void incrementExecuteCount()
Increments the number of times Statement.execute() has been called

Specified by:
incrementExecuteCount in interface ConnectionStats

getExecuteCount

public int getExecuteCount()
Returns the number of times Statement.execute() has been called


incrementGetMoreResultsCount

public void incrementGetMoreResultsCount()
Increments the number of times Statement.getMoreResults() has been called

Specified by:
incrementGetMoreResultsCount in interface ConnectionStats

getGetMoreResultsCount

public int getGetMoreResultsCount()
Returns the number of times Statement.getMoreResults() has been called


incrementResultSetRowCount

public void incrementResultSetRowCount()
Increments the number of times ResultSet.next() has been called

Specified by:
incrementResultSetRowCount in interface ConnectionStats

getResultSetRowCount

public int getResultSetRowCount()
Returns the number of times ResultSet.next() has been called


unwrap

public <T> T unwrap(java.lang.Class<T> pInterface)
         throws java.sql.SQLException
Returns an object that implements the given interface

Specified by:
unwrap in interface java.sql.Wrapper
Parameters:
pInterface - the interface of the object to return
Throws:
java.sql.SQLException - if no object is found that implements the given interface
Since:
1.6

isWrapperFor

public boolean isWrapperFor(java.lang.Class<?> pInterface)
                     throws java.sql.SQLException
Returns true if this class implements the pInterface argument

Specified by:
isWrapperFor in interface java.sql.Wrapper
Parameters:
pInterface - the interface to test
Returns:
true of this instance implements the interface, false otherwise
Throws:
java.sql.SQLException - if there's an error determining whether this is a wrapper for the interface
Since:
1.6

co

protected ResourceObject co(java.lang.String pCheckOutTag)
                     throws ResourcePoolException
The internal resource checkout method. Some final preparations are made to the resource before being handed to calling methods.

Returns:
The object or null if mConfig.mPoolMax has been reached
Throws:
ResourcePoolException - if an error occurred during the operation

ci

protected void ci(ResourceObject pResource)
           throws ResourcePoolException
Checks a resource into the pool.

Parameters:
pResource - a resource checked out from this pool
Throws:
ResourcePoolException - if an error occurred during the operation

reclaimResource

protected void reclaimResource(ResourceObject pRobj)
                        throws ResourcePoolException
Reclaims a resource that is most likely out of the pool.

Overrides:
reclaimResource in class ResourcePool
Throws:
ResourcePoolException

addAdminInfo

protected void addAdminInfo(javax.servlet.http.HttpServletRequest pRequest,
                            javax.servlet.http.HttpServletResponse pResponse,
                            javax.servlet.ServletOutputStream pOut)
                     throws javax.servlet.ServletException,
                            java.io.IOException
Adds to the HTML Admin response any information specific to the the ResourcePool subclass. Yes, this is a hack.

Overrides:
addAdminInfo in class ResourcePool
Throws:
javax.servlet.ServletException
java.io.IOException