|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.knowgate.jdc.JDCConnectionPool
public final class JDCConnectionPool
JDBC Connection Pool
Implementation of a standard JDBC connection pool.
| Constructor Summary | |
|---|---|
JDCConnectionPool(java.lang.Object bind,
java.lang.String url,
java.lang.String user,
java.lang.String password,
int maxpoolsize,
int maxconnections)
Constructor This method sets a default login timeout of 20 seconds |
|
JDCConnectionPool(java.lang.Object bind,
java.lang.String url,
java.lang.String user,
java.lang.String password,
int maxpoolsize,
int maxconnections,
int logintimeout)
Constructor This method sets a default login timeout of 20 seconds |
|
JDCConnectionPool(java.lang.Object bind,
java.lang.String url,
java.lang.String user,
java.lang.String password,
int maxpoolsize,
int maxconnections,
int logintimeout,
long connectiontimeout)
Constructor This method sets a default login timeout of 20 seconds |
|
JDCConnectionPool(java.lang.String url,
java.lang.String user,
java.lang.String password)
Constructor By default, maximum pool size is set to 32, maximum opened connections is 100, login timeout is 20 seconds, connection timeout is 5 minutes. |
|
JDCConnectionPool(java.lang.String url,
java.lang.String user,
java.lang.String password,
int maxpoolsize,
int maxconnections)
Constructor This method sets a default login timeout of 20 seconds |
|
JDCConnectionPool(java.lang.String url,
java.lang.String user,
java.lang.String password,
int maxpoolsize,
int maxconnections,
int logintimeout)
Constructor |
|
| Method Summary | |
|---|---|
void |
close()
Close all connections and stop connection reaper |
void |
closeConnections()
Close all connections from the pool regardless of their current state |
int |
closeStaledConnections()
Close connections from the pool not used for a longer time |
java.lang.String |
dumpStatistics()
Human readable usage statistics |
JDCActivityInfo |
getActivityInfo()
Get information of current activity at database to which this pool is connected |
JDCConnection[] |
getAllConnections()
Get an array with references to all pooled connections |
JDCConnection |
getConnection(java.lang.String sCaller)
Get a connection from the pool |
JDCConnection |
getConnectionForPId(java.lang.String sPId)
Get conenction for a server process identifier |
java.lang.Object |
getDatabaseBinding()
Get the DBbind object owner of this conenction pool |
int |
getLoginTimeout()
Get login timeout from java.sql.DriverManager |
java.io.PrintWriter |
getLogWriter()
Get LogWriter from java.sql.DriverManager |
int |
getMaxPoolSize()
Absolute maximum allowed for concurrent opened connections. |
javax.sql.PooledConnection |
getPooledConnection()
Get a connection from the pool |
javax.sql.PooledConnection |
getPooledConnection(java.lang.String sUser,
java.lang.String sPasswd)
Get a connection bypassing the pool and connection directly to the database with the given user and password |
int |
getPoolSize()
Get prefered open connections limit Additional connections beyond PoolSize may be opened but they will closed inmediately after use and not pooled. |
long |
getReaperDaemonDelay()
Delay betwwen connection reaper executions |
long |
getTimeout()
Get staled connection threshold The default value is 600000ms (10 mins.) |
void |
returnConnection(JDCConnection conn)
Return a connection to the pool |
void |
returnConnection(JDCConnection conn,
java.lang.String sCaller)
Return a connection to the pool |
void |
setLoginTimeout(int seconds)
Set login timeout for java.sql.DriverManager |
void |
setLogWriter(java.io.PrintWriter printwrt)
Set LogWriter for java.sql.DriverManager |
void |
setMaxPoolSize(int iMaxConnections)
Set maximum concurrent open connections limit The default value is 100. |
void |
setPoolSize(int iPoolSize)
Set prefered open connections limit Additional connections beyond PoolSize may be opened but they will closed inmediately after use and not pooled. |
void |
setReaperDaemonDelay(long lDelayMs)
Set delay betwwen connection reaper executions (default value is 5 mins) |
void |
setTimeout(long miliseconds)
Set staled connection threshold |
int |
size()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JDCConnectionPool(java.lang.String url,
java.lang.String user,
java.lang.String password)
url - JDBC URL stringuser - Database userpassword - Password for user
public JDCConnectionPool(java.lang.Object bind,
java.lang.String url,
java.lang.String user,
java.lang.String password,
int maxpoolsize,
int maxconnections,
int logintimeout,
long connectiontimeout)
Constructor
This method sets a default login timeout of 20 seconds
bind - DBBind owner of the connection pool (may be null)url - JDBC URL stringuser - Database userpassword - Password for usermaxpoolsize - Maximum pool sizemaxconnections - Maximum opened connectionsconnectiontimeout - Maximum time that alogintimeout - Maximum time, in seconds, to wait for connection
public JDCConnectionPool(java.lang.Object bind,
java.lang.String url,
java.lang.String user,
java.lang.String password,
int maxpoolsize,
int maxconnections,
int logintimeout)
Constructor
This method sets a default login timeout of 20 seconds
bind - DBBind owner of the connection pool (may be null)url - JDBC URL stringuser - Database userpassword - Password for usermaxpoolsize - Maximum pool sizemaxconnections - Maximum opened connectionslogintimeout - Maximum time, in seconds, to wait for connection
public JDCConnectionPool(java.lang.Object bind,
java.lang.String url,
java.lang.String user,
java.lang.String password,
int maxpoolsize,
int maxconnections)
Constructor
This method sets a default login timeout of 20 seconds
bind - DBBind owner of the connection pool (may be null)url - JDBC URL stringuser - Database userpassword - Password for usermaxpoolsize - Maximum pool size (Default 32)maxconnections - Maximum opened connections (Default 100)
public JDCConnectionPool(java.lang.String url,
java.lang.String user,
java.lang.String password,
int maxpoolsize,
int maxconnections,
int logintimeout)
Constructor
url - JDBC URL stringuser - Database userpassword - Password for usermaxpoolsize - Maximum pool size (Default 32)maxconnections - Maximum opened connections (Default 100)logintimeout - Maximum time, in seconds, to wait for connection
public JDCConnectionPool(java.lang.String url,
java.lang.String user,
java.lang.String password,
int maxpoolsize,
int maxconnections)
Constructor
This method sets a default login timeout of 20 seconds
url - JDBC URL stringuser - Database userpassword - Password for usermaxpoolsize - Maximum pool size (Default 32)maxconnections - Maximum opened connections (Default 100)| Method Detail |
|---|
public void close()
public int getPoolSize()
Get prefered open connections limit
Additional connections beyond PoolSize may be opened but they
will closed inmediately after use and not pooled.
The default value is 32.
public void setPoolSize(int iPoolSize)
Set prefered open connections limit
Additional connections beyond PoolSize may be opened but they
will closed inmediately after use and not pooled.
The default value is 32.
Connections not being used can only be in the pool for a maximum of five minutes.
After a connection is not used for over 5 minutes it will be closed so the actual
pool size will eventually go down to zero after a period of inactivity.
iPoolSize - Maximum pooled connectionspublic void setMaxPoolSize(int iMaxConnections)
Set maximum concurrent open connections limit
The default value is 100.
iMaxConnections - Absolute maximum for opened connectionspublic int getMaxPoolSize()
Absolute maximum allowed for concurrent opened connections.
The default value is 100.
public java.io.PrintWriter getLogWriter()
throws java.sql.SQLException
getLogWriter in interface javax.sql.CommonDataSourcejava.sql.SQLException
public void setLogWriter(java.io.PrintWriter printwrt)
throws java.sql.SQLException
setLogWriter in interface javax.sql.CommonDataSourcejava.sql.SQLException
public int getLoginTimeout()
throws java.sql.SQLException
getLoginTimeout in interface javax.sql.CommonDataSourcejava.sql.SQLException
public void setLoginTimeout(int seconds)
throws java.sql.SQLException
setLoginTimeout in interface javax.sql.CommonDataSourcejava.sql.SQLExceptionpublic long getTimeout()
Get staled connection threshold
The default value is 600000ms (10 mins.)
public void setTimeout(long miliseconds)
throws java.lang.IllegalArgumentException
Set staled connection threshold
miliseconds - The maximum amount of time in miliseconds that a JDCConnection
can be opened and not used before considering it staled.java.lang.IllegalArgumentException - If miliseconds<1000public long getReaperDaemonDelay()
public void setReaperDaemonDelay(long lDelayMs)
throws java.lang.IllegalArgumentException
lDelayMs - long Miliseconds
java.lang.IllegalArgumentException - if lDelayMs is less than 1000public void closeConnections()
public int closeStaledConnections()
public JDCConnection[] getAllConnections()
public java.lang.Object getDatabaseBinding()
public JDCConnection getConnection(java.lang.String sCaller)
throws java.sql.SQLException
sCaller - This is just an information parameter used for open/closed
mismatch tracking and other benchmarking and statistical purposes.
java.sql.SQLException - If getMaxPoolSize() opened connections is reached an
SQLException with SQLState="08004" will be raised upon calling getConnection().
public javax.sql.PooledConnection getPooledConnection()
throws java.sql.SQLException
getPooledConnection in interface javax.sql.ConnectionPoolDataSourcejava.sql.SQLException - If getMaxPoolSize() opened connections is reached an
SQLException with SQLState="08004" will be raised upon calling getConnection().
public javax.sql.PooledConnection getPooledConnection(java.lang.String sUser,
java.lang.String sPasswd)
throws java.sql.SQLException
getPooledConnection in interface javax.sql.ConnectionPoolDataSourcesUser - sPasswd -
java.sql.SQLException
public JDCConnection getConnectionForPId(java.lang.String sPId)
throws java.sql.SQLException
sPId - String Operating system process identifier at server side
java.sql.SQLExceptionpublic void returnConnection(JDCConnection conn)
conn - JDCConnection returned to the pool
public void returnConnection(JDCConnection conn,
java.lang.String sCaller)
conn - JDCConnection returned to the poolsCaller - Must be the same String passed as parameter at getConnection()public int size()
public JDCActivityInfo getActivityInfo()
throws java.sql.SQLException
java.sql.SQLException
public java.lang.String dumpStatistics()
throws java.util.ConcurrentModificationException
java.util.ConcurrentModificationException - If pool is modified while iterating
throught connection collection
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||