public class StandardPoolDataSource extends CoreDataSource implements DataSource, PoolHelper, ConnectionEventListener
create : create a PooledConnection
create(user,password) : create a PooledConnection with an other user/password
testThisObject : check if the object is still valid
checkThisObject : check if the object is closed
expire : kill the object
| Modifier and Type | Field and Description |
|---|---|
ConnectionPoolDataSource |
cpds |
String |
dataSourceName |
org.apache.commons.logging.Log |
glog |
Context |
ictx |
String |
jdbcTestStmt |
boolean |
onOff |
GenericPool |
pool |
logWriter, password, user| Constructor and Description |
|---|
StandardPoolDataSource()
Constructor
|
StandardPoolDataSource(ConnectionPoolDataSource cc)
Constructor
|
StandardPoolDataSource(ConnectionPoolDataSource cc,
int initSize)
Constructor
|
StandardPoolDataSource(int initSize)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkThisObject(Object o)
This method tests if a connection is closed or not
|
void |
connectionClosed(ConnectionEvent event)
Invoked when the application calls close()
on its representation of the connection
|
void |
connectionErrorOccurred(ConnectionEvent event)
connectionErrorOccurred and connectionClosed are methods
from ConnectionEventListener interface
Invoked when a fatal connection error occurs,
just before an SQLException is thrown to the application
|
GenerationObject |
create() |
GenerationObject |
create(String _user,
String _password) |
void |
expire(Object o)
object specific work to kill the object
|
int |
getCheckLevelObject() |
Connection |
getConnection()
getConnection allows to get an object from the pool and returns it
to the user.
|
Connection |
getConnection(String _user,
String _password)
getConnection allows to get an object from the pool and returns it
to the user.
|
String |
getDataSourceName() |
long |
getDeadLockMaxWait() |
long |
getDeadLockRetryWait() |
int |
getGeneration() |
String |
getJdbcTestStmt() |
long |
getLifeTime() |
int |
getLockedObjectCount() |
PrintWriter |
getLogWriter() |
int |
getMaxSize() |
int |
getMinSize() |
Object |
getObjectInstance(Object refObj,
Name name,
Context nameCtx,
Hashtable env)
Methods inherited from ObjectFactory
|
Logger |
getParentLogger() |
Reference |
getReference()
Retrieves the Reference of this object.
|
long |
getSleepTime() |
int |
getUnlockedObjectCount() |
boolean |
isGC() |
boolean |
isWrapperFor(Class<?> iface) |
void |
setCheckLevelObject(int checkLevelObject)
set the check level of the pooled object before using them
|
void |
setDataSourceName(String dataSourceName)
Set up the data source name, get the initial context,
and lookup in JNDI to obtain a reference of the DataSourceName
this method must be called before a getConnection (in this case
an exception is returned
|
void |
setDeadLockMaxWait(long deadLock)
set the global time the pool can wait for a free object
|
void |
setDeadLockRetryWait(long loopWait)
set the time before 2 tries when trying to obtain an object from the pool
|
void |
setDebug(boolean debug)
set the debug flag
|
void |
setGC(boolean gc)
set the garbage collection option
|
void |
setGeneration(int generation)
set the generation number for future connection, the generation number
is used to identify a group a created objects
|
void |
setJdbcTestStmt(String jdbcTestStmt)
set the String to test the jdbc connection before using it
|
void |
setLifeTime(long lifeTime)
set the life time of the pooled objects
|
void |
setLogWriter(PrintWriter logWriter)
set the logwriter for the current object, the logwriter will be use by
the current object and by the generic pool
|
void |
setMaxSize(int maxSize)
set the maximum size of the pool
|
void |
setMinSize(int minSize)
set the minimum size of the pool
|
void |
setSleepTime(long sleepTime)
set the sleep time of pooled objects
|
void |
setThreadFactory(JdbcThreadFactory tf)
Override this so that the pool's tf gets set as well
|
void |
shutdown(boolean force)
shutdown is a placeholder for datasources which should shut down
any pools which they maintain.
|
void |
stopPool()
stop method to switch off the pool
|
boolean |
testThisObject(Object o)
This method tests if a connection is valid or not
|
String |
toString() |
<T> T |
unwrap(Class<T> iface) |
getDescription, getLoginTimeout, getPassword, getThreadFactory, getUser, isDebug, isVerbose, setDescription, setLoginTimeout, setPassword, setUser, setVerboseclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetLoginTimeout, setLoginTimeoutpublic ConnectionPoolDataSource cpds
public GenericPool pool
public String dataSourceName
public String jdbcTestStmt
public boolean onOff
public Context ictx
public org.apache.commons.logging.Log glog
public StandardPoolDataSource()
public StandardPoolDataSource(int initSize)
public StandardPoolDataSource(ConnectionPoolDataSource cc)
public StandardPoolDataSource(ConnectionPoolDataSource cc, int initSize)
public void setDataSourceName(String dataSourceName)
public String getDataSourceName()
public Connection getConnection() throws SQLException
getConnection in interface DataSourceSQLExceptionpublic Connection getConnection(String _user, String _password) throws SQLException
getConnection in interface DataSourceSQLExceptionpublic void connectionErrorOccurred(ConnectionEvent event)
connectionErrorOccurred in interface ConnectionEventListenerpublic void connectionClosed(ConnectionEvent event)
connectionClosed in interface ConnectionEventListenerpublic void expire(Object o)
expire in interface PoolHelperpublic boolean checkThisObject(Object o)
checkThisObject in interface PoolHelperpublic boolean testThisObject(Object o)
testThisObject in interface PoolHelperpublic GenerationObject create() throws SQLException
create in interface PoolHelperSQLExceptionpublic GenerationObject create(String _user, String _password) throws SQLException
create in interface PoolHelperSQLExceptionpublic void stopPool()
public void shutdown(boolean force)
CoreDataSourceshutdown in class CoreDataSourcepublic void setLogWriter(PrintWriter logWriter)
setLogWriter in interface CommonDataSourcesetLogWriter in class CoreDataSourcelogWriter - a PrintWriter objectpublic void setDebug(boolean debug)
setDebug in class CoreDataSourcedebug - a boolean flagpublic void setMinSize(int minSize)
throws Exception
minSize - minimum size of the poolExceptionpublic void setMaxSize(int maxSize)
throws Exception
maxSize - maximum size of the poolExceptionpublic void setLifeTime(long lifeTime)
lifeTime - life time of the pooled objects (in milliseconds)public void setSleepTime(long sleepTime)
sleepTime - sleep time of the pooled objects (in milliseconds)public void setGC(boolean gc)
gc - true: the garbage collector will be launched when clean up of the
pool, else falsepublic void setCheckLevelObject(int checkLevelObject)
checkLevelObject - (public void setJdbcTestStmt(String jdbcTestStmt)
jdbcTestStmt - an sql statementpublic void setGeneration(int generation)
generation - an integer value which represents a generationpublic void setDeadLockMaxWait(long deadLock)
deadLock - in millisecondspublic void setDeadLockRetryWait(long loopWait)
loopWait - in millisecondspublic PrintWriter getLogWriter()
getLogWriter in interface CommonDataSourcegetLogWriter in class CoreDataSourcepublic int getMinSize()
public int getMaxSize()
public long getLifeTime()
public long getSleepTime()
public int getGeneration()
public boolean isGC()
public int getLockedObjectCount()
public int getUnlockedObjectCount()
public int getCheckLevelObject()
public String getJdbcTestStmt()
public long getDeadLockMaxWait()
public long getDeadLockRetryWait()
public String toString()
toString in interface PoolHelpertoString in class CoreDataSourcepublic Reference getReference() throws NamingException
getReference in interface ReferenceablegetReference in class CoreDataSourceNamingException - If a naming exception was encountered while
retrieving the reference.public Object getObjectInstance(Object refObj, Name name, Context nameCtx, Hashtable env) throws Exception
CoreDataSourcegetObjectInstance in interface ObjectFactorygetObjectInstance in class CoreDataSourceExceptionpublic void setThreadFactory(JdbcThreadFactory tf)
setThreadFactory in class CoreDataSourcepublic boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor in interface WrapperSQLExceptionpublic <T> T unwrap(Class<T> iface) throws SQLException
unwrap in interface WrapperSQLExceptionpublic Logger getParentLogger() throws SQLFeatureNotSupportedException
getParentLogger in interface CommonDataSourceSQLFeatureNotSupportedExceptionCopyright © 2014–2015. All rights reserved.