public class StandardPoolDataSource extends CoreDataSource implements javax.sql.DataSource, PoolHelper, javax.sql.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 |
---|---|
javax.sql.ConnectionPoolDataSource |
cpds |
java.lang.String |
dataSourceName |
org.apache.commons.logging.Log |
glog |
javax.naming.Context |
ictx |
java.lang.String |
jdbcTestStmt |
boolean |
onOff |
GenericPool |
pool |
logWriter, password, user
Constructor and Description |
---|
StandardPoolDataSource()
Constructor
|
StandardPoolDataSource(javax.sql.ConnectionPoolDataSource cc)
Constructor
|
StandardPoolDataSource(javax.sql.ConnectionPoolDataSource cc,
int initSize)
Constructor
|
StandardPoolDataSource(int initSize)
Constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkThisObject(java.lang.Object o)
This method tests if a connection is closed or not
|
void |
connectionClosed(javax.sql.ConnectionEvent event)
Invoked when the application calls close()
on its representation of the connection
|
void |
connectionErrorOccurred(javax.sql.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(java.lang.String _user,
java.lang.String _password) |
void |
expire(java.lang.Object o)
object specific work to kill the object
|
int |
getCheckLevelObject() |
java.sql.Connection |
getConnection()
getConnection allows to get an object from the pool and returns it
to the user.
|
java.sql.Connection |
getConnection(java.lang.String _user,
java.lang.String _password)
getConnection allows to get an object from the pool and returns it
to the user.
|
java.lang.String |
getDataSourceName() |
long |
getDeadLockMaxWait() |
long |
getDeadLockRetryWait() |
int |
getGeneration() |
java.lang.String |
getJdbcTestStmt() |
long |
getLifeTime() |
int |
getLockedObjectCount() |
java.io.PrintWriter |
getLogWriter() |
int |
getMaxSize() |
int |
getMinSize() |
java.lang.Object |
getObjectInstance(java.lang.Object refObj,
javax.naming.Name name,
javax.naming.Context nameCtx,
java.util.Hashtable env)
Methods inherited from ObjectFactory
|
java.util.logging.Logger |
getParentLogger() |
javax.naming.Reference |
getReference()
Retrieves the Reference of this object.
|
long |
getSleepTime() |
int |
getUnlockedObjectCount() |
boolean |
isGC() |
boolean |
isWrapperFor(java.lang.Class<?> iface) |
void |
setCheckLevelObject(int checkLevelObject)
set the check level of the pooled object before using them
|
void |
setDataSourceName(java.lang.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(java.lang.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(java.io.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(java.lang.Object o)
This method tests if a connection is valid or not
|
java.lang.String |
toString() |
<T> T |
unwrap(java.lang.Class<T> iface) |
getDescription, getLoginTimeout, getPassword, getThreadFactory, getUser, isDebug, isVerbose, setDescription, setLoginTimeout, setPassword, setUser, setVerbose
public javax.sql.ConnectionPoolDataSource cpds
public GenericPool pool
public java.lang.String dataSourceName
public java.lang.String jdbcTestStmt
public boolean onOff
public javax.naming.Context ictx
public org.apache.commons.logging.Log glog
public StandardPoolDataSource()
public StandardPoolDataSource(int initSize)
public StandardPoolDataSource(javax.sql.ConnectionPoolDataSource cc)
public StandardPoolDataSource(javax.sql.ConnectionPoolDataSource cc, int initSize)
public void setDataSourceName(java.lang.String dataSourceName)
public java.lang.String getDataSourceName()
public java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
public java.sql.Connection getConnection(java.lang.String _user, java.lang.String _password) throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
public void connectionErrorOccurred(javax.sql.ConnectionEvent event)
connectionErrorOccurred
in interface javax.sql.ConnectionEventListener
public void connectionClosed(javax.sql.ConnectionEvent event)
connectionClosed
in interface javax.sql.ConnectionEventListener
public void expire(java.lang.Object o)
expire
in interface PoolHelper
public boolean checkThisObject(java.lang.Object o)
checkThisObject
in interface PoolHelper
public boolean testThisObject(java.lang.Object o)
testThisObject
in interface PoolHelper
public GenerationObject create() throws java.sql.SQLException
create
in interface PoolHelper
java.sql.SQLException
public GenerationObject create(java.lang.String _user, java.lang.String _password) throws java.sql.SQLException
create
in interface PoolHelper
java.sql.SQLException
public void stopPool()
public void shutdown(boolean force)
CoreDataSource
shutdown
in class CoreDataSource
public void setLogWriter(java.io.PrintWriter logWriter)
setLogWriter
in interface javax.sql.CommonDataSource
setLogWriter
in class CoreDataSource
logWriter
- a PrintWriter objectpublic void setDebug(boolean debug)
setDebug
in class CoreDataSource
debug
- a boolean flagpublic void setMinSize(int minSize) throws java.lang.Exception
minSize
- minimum size of the pooljava.lang.Exception
public void setMaxSize(int maxSize) throws java.lang.Exception
maxSize
- maximum size of the pooljava.lang.Exception
public 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(java.lang.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 java.io.PrintWriter getLogWriter()
getLogWriter
in interface javax.sql.CommonDataSource
getLogWriter
in class CoreDataSource
public 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 java.lang.String getJdbcTestStmt()
public long getDeadLockMaxWait()
public long getDeadLockRetryWait()
public java.lang.String toString()
toString
in interface PoolHelper
toString
in class CoreDataSource
public javax.naming.Reference getReference() throws javax.naming.NamingException
getReference
in interface javax.naming.Referenceable
getReference
in class CoreDataSource
javax.naming.NamingException
- If a naming exception was encountered while
retrieving the reference.public java.lang.Object getObjectInstance(java.lang.Object refObj, javax.naming.Name name, javax.naming.Context nameCtx, java.util.Hashtable env) throws java.lang.Exception
CoreDataSource
getObjectInstance
in interface javax.naming.spi.ObjectFactory
getObjectInstance
in class CoreDataSource
java.lang.Exception
public void setThreadFactory(JdbcThreadFactory tf)
setThreadFactory
in class CoreDataSource
public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException
getParentLogger
in interface javax.sql.CommonDataSource
java.sql.SQLFeatureNotSupportedException
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException
isWrapperFor
in interface java.sql.Wrapper
java.sql.SQLException
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
unwrap
in interface java.sql.Wrapper
java.sql.SQLException