Top Description Fields Constructors Methods
org.apache.tomcat.jdbc.pool

public Class DataSourceFactory

extends Object
implements ObjectFactory
Class Inheritance
All Implemented Interfaces
javax.naming.spi.ObjectFactory
Imports
java.sql.Connection, java.util.Hashtable, .Properties, javax.management.ObjectName, javax.naming.Context, .InitialContext, .Name, .NamingException, .RefAddr, .Reference, javax.naming.spi.ObjectFactory, javax.sql.DataSource, org.apache.juli.logging.Log, .LogFactory

JNDI object factory that creates an instance of BasicDataSource that has been configured based on the RefAddr values of the specified Reference, which must match the names and data types of the BasicDataSource bean properties.


Properties available for configuration:
Commons DBCP properties
  1. initSQL - A query that gets executed once, right after the connection is established.
  2. testOnConnect - run validationQuery after connection has been established.
  3. validationInterval - avoid excess validation, only run validation at most at this frequency - time in milliseconds.
  4. jdbcInterceptors - a semicolon separated list of classnames extending JdbcInterceptor class.
  5. jmxEnabled - true of false, whether to register the pool with JMX.
  6. fairQueue - true of false, whether the pool should sacrifice a little bit of performance for true fairness.
Authors
Craig R. McClanahan, Dirk Verbeeck

Field Summary

Modifier and TypeField and Description
protected static final String[]
private static final Log
public static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
public static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public DataSource

Returns:

the datasource
createDataSource
(Properties
the datasource configuration properties
properties
)

Creates and configures a DataSource instance based on the given properties.

public DataSource
createDataSource(Properties properties, Context context, boolean XA)

public Object
getObjectInstance(Object
The possibly null object containing location or reference information that can be used in creating an object
obj
,
Name
The name of this object relative to nameCtx
name
,
Context
The context relative to which the name parameter is specified, or null if name is relative to the default initial context
nameCtx
,
Hashtable<?, ?>
The possibly null environment that is used in creating this object
environment
)

Implements javax.naming.spi.ObjectFactory.getObjectInstance.

Create and return a new BasicDataSource instance.

protected static Properties

Returns:

the properties
getProperties
(String
The properties string
propText
)

Parse properties from the string.

public static PoolConfiguration
public void
performJNDILookup(Context context, PoolConfiguration poolProperties)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALL_PROPERTIESback to summary
protected static final String[] ALL_PROPERTIES
logback to summary
private static final Log log
OBJECT_NAMEback to summary
public static final String OBJECT_NAME
PROP_ABANDONWHENPERCENTAGEFULLback to summary
protected static final String PROP_ABANDONWHENPERCENTAGEFULL
PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWEDback to summary
protected static final String PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWED
PROP_ALTERNATE_USERNAME_ALLOWEDback to summary
protected static final String PROP_ALTERNATE_USERNAME_ALLOWED
PROP_COMMITONRETURNback to summary
protected static final String PROP_COMMITONRETURN
PROP_CONNECTIONPROPERTIESback to summary
protected static final String PROP_CONNECTIONPROPERTIES
PROP_DATASOURCEback to summary
protected static final String PROP_DATASOURCE
PROP_DATASOURCE_JNDIback to summary
protected static final String PROP_DATASOURCE_JNDI
PROP_DEFAULTAUTOCOMMITback to summary
protected static final String PROP_DEFAULTAUTOCOMMIT
PROP_DEFAULTCATALOGback to summary
protected static final String PROP_DEFAULTCATALOG
PROP_DEFAULTREADONLYback to summary
protected static final String PROP_DEFAULTREADONLY
PROP_DEFAULTTRANSACTIONISOLATIONback to summary
protected static final String PROP_DEFAULTTRANSACTIONISOLATION
PROP_DRIVERCLASSNAMEback to summary
protected static final String PROP_DRIVERCLASSNAME
PROP_FAIR_QUEUEback to summary
protected static final String PROP_FAIR_QUEUE
PROP_IGNOREEXCEPTIONONPRELOADback to summary
protected static final String PROP_IGNOREEXCEPTIONONPRELOAD
PROP_INITIALSIZEback to summary
protected static final String PROP_INITIALSIZE
PROP_INITSQLback to summary
protected static final String PROP_INITSQL
PROP_INTERCEPTORSback to summary
protected static final String PROP_INTERCEPTORS
PROP_JMX_ENABLEDback to summary
protected static final String PROP_JMX_ENABLED
PROP_LOGABANDONEDback to summary
protected static final String PROP_LOGABANDONED
PROP_LOGVALIDATIONERRORSback to summary
protected static final String PROP_LOGVALIDATIONERRORS
PROP_MAXACTIVEback to summary
protected static final String PROP_MAXACTIVE
PROP_MAXAGEback to summary
protected static final String PROP_MAXAGE
PROP_MAXIDLEback to summary
protected static final String PROP_MAXIDLE
PROP_MAXOPENPREPAREDSTATEMENTSback to summary
protected static final String PROP_MAXOPENPREPAREDSTATEMENTS
PROP_MAXWAITback to summary
protected static final String PROP_MAXWAIT
PROP_MINEVICTABLEIDLETIMEMILLISback to summary
protected static final String PROP_MINEVICTABLEIDLETIMEMILLIS
PROP_MINIDLEback to summary
protected static final String PROP_MINIDLE
PROP_NUMTESTSPEREVICTIONRUNback to summary
protected static final String PROP_NUMTESTSPEREVICTIONRUN
PROP_PASSWORDback to summary
protected static final String PROP_PASSWORD
PROP_POOLPREPAREDSTATEMENTSback to summary
protected static final String PROP_POOLPREPAREDSTATEMENTS
PROP_PROPAGATEINTERRUPTSTATEback to summary
protected static final String PROP_PROPAGATEINTERRUPTSTATE
PROP_REMOVEABANDONEDback to summary
protected static final String PROP_REMOVEABANDONED
PROP_REMOVEABANDONEDTIMEOUTback to summary
protected static final String PROP_REMOVEABANDONEDTIMEOUT
PROP_ROLLBACKONRETURNback to summary
protected static final String PROP_ROLLBACKONRETURN
PROP_SUSPECT_TIMEOUTback to summary
protected static final String PROP_SUSPECT_TIMEOUT
PROP_TESTONBORROWback to summary
protected static final String PROP_TESTONBORROW
PROP_TESTONCONNECTback to summary
protected static final String PROP_TESTONCONNECT
PROP_TESTONRETURNback to summary
protected static final String PROP_TESTONRETURN
PROP_TESTWHILEIDLEback to summary
protected static final String PROP_TESTWHILEIDLE
PROP_TIMEBETWEENEVICTIONRUNSMILLISback to summary
protected static final String PROP_TIMEBETWEENEVICTIONRUNSMILLIS
PROP_URLback to summary
protected static final String PROP_URL
PROP_USE_CON_LOCKback to summary
protected static final String PROP_USE_CON_LOCK
PROP_USE_EQUALSback to summary
protected static final String PROP_USE_EQUALS
PROP_USEDISPOSABLECONNECTIONFACADEback to summary
protected static final String PROP_USEDISPOSABLECONNECTIONFACADE
PROP_USERNAMEback to summary
protected static final String PROP_USERNAME
PROP_USESTATEMENTFACADEback to summary
protected static final String PROP_USESTATEMENTFACADE
PROP_VALIDATIONINTERVALback to summary
protected static final String PROP_VALIDATIONINTERVAL
PROP_VALIDATIONQUERYback to summary
protected static final String PROP_VALIDATIONQUERY
PROP_VALIDATIONQUERY_TIMEOUTback to summary
protected static final String PROP_VALIDATIONQUERY_TIMEOUT
PROP_VALIDATOR_CLASS_NAMEback to summary
protected static final String PROP_VALIDATOR_CLASS_NAME
UNKNOWN_TRANSACTIONISOLATIONback to summary
public static final int UNKNOWN_TRANSACTIONISOLATION

Constructor Detail

DataSourceFactoryback to summary
public DataSourceFactory()

Method Detail

createDataSourceback to summary
public DataSource createDataSource(Properties properties) throws Exception

Creates and configures a DataSource instance based on the given properties.

Parameters
properties:Properties

the datasource configuration properties

Returns:DataSource

the datasource

Exceptions
Exception:
if an error occurs creating the data source
createDataSourceback to summary
public DataSource createDataSource(Properties properties, Context context, boolean XA) throws Exception
getObjectInstanceback to summary
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception

Implements javax.naming.spi.ObjectFactory.getObjectInstance.

Create and return a new BasicDataSource instance. If no instance can be created, return null instead.

Parameters
obj:Object

The possibly null object containing location or reference information that can be used in creating an object

name:Name

The name of this object relative to nameCtx

nameCtx:Context

The context relative to which the name parameter is specified, or null if name is relative to the default initial context

environment:Hashtable<?, ?>

The possibly null environment that is used in creating this object

Returns:Object

Doc from javax.naming.spi.ObjectFactory.getObjectInstance.

The object created; null if an object cannot be created.

Annotations
@Override
Exceptions
Exception:
if an exception occurs creating the instance
getPropertiesback to summary
protected static Properties getProperties(String propText)

Parse properties from the string. Format of the string must be [propertyName=property;]*.

Parameters
propText:String

The properties string

Returns:Properties

the properties

parsePoolPropertiesback to summary
public static PoolConfiguration parsePoolProperties(Properties properties)
performJNDILookupback to summary
public void performJNDILookup(Context context, PoolConfiguration poolProperties)