|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jso.sql.DynamicPool
Manages a dynamic pool of database connections that may grow or shrink
according to demand. The growth, or shrinkage, of the pool size is, whenever
possible, made by minSize
connections, where minSize
is the minimum size of the pool.
Field Summary | |
static int |
DEFAULT_MAX_SIZE
Default maximum size for pool. |
static int |
DEFAULT_MIN_SIZE
Default minimum size for pool. (5 connections) |
Constructor Summary | |
DynamicPool()
Constructs the pool. |
|
DynamicPool(java.io.InputStream aStream)
Constructs the pool. |
|
DynamicPool(int aMin,
int aMax)
Constructs the pool. |
|
DynamicPool(java.util.Properties properties)
Constructs the pool. |
Method Summary | |
java.sql.Connection |
borrowConnection()
Borrows a connection from the pool. |
int |
capacity()
Returns the maximum pool size. |
void |
close()
Closes the pool. |
protected void |
finalize()
Cleans the pool before it's garbage collected. |
ConnectionPoolInfo |
getPoolInfo()
Gets connection pool information. |
int |
idle()
Returns the number of idle connections. |
int |
inUse()
Returns the number of used connections. |
boolean |
isOpen()
Indicates if the pool is open. |
int |
maxSize()
Returns the pool maximum size. |
int |
minSize()
Returns the pool minimum size. |
void |
open(java.lang.String anUrl,
java.lang.String anUser,
java.lang.String aPassword)
Opens the pool. |
void |
open(java.lang.String aDriverClass,
java.lang.String anUrl,
java.lang.String anUser,
java.lang.String aPassword)
Opens the pool. |
void |
returnConnection(java.sql.Connection aConnection)
Returns a connection to the pool. |
int |
size()
Returns the current pool size. |
java.lang.String |
url()
Returns the current database url. |
java.lang.String |
user()
Returns the current database user. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_MIN_SIZE
public static final int DEFAULT_MAX_SIZE
Constructor Detail |
public DynamicPool()
net.sf.jso.sql.DynamicPool.properties
exists in the current
directory or in the classpath it is used.
DynamicPool(Properties)
public DynamicPool(java.io.InputStream aStream) throws java.io.IOException
aStream
- Input stream of a properties file with parameters.Properties.load(InputStream)
,
DynamicPool(Properties)
public DynamicPool(java.util.Properties properties)
properties
- Parameters for the pool. Properties minSize
and maxSize
can be used. Those values are used as the pool minimun
and maximum size, respectively. Otherwise
a default minimun size and
a default maximun size are used.public DynamicPool(int aMin, int aMax) throws java.lang.IllegalArgumentException
aMin
- The minimum number of connections the pool will manage.aMax
- The maximum number of connections the pool will manage.Method Detail |
public java.lang.String url()
public java.lang.String user()
public int minSize()
public int maxSize()
public int capacity()
capacity
in interface ConnectionPoolInfo
public int size()
size
in interface ConnectionPoolInfo
public int idle()
idle
in interface ConnectionPoolInfo
public int inUse()
inUse
in interface ConnectionPoolInfo
public void open(java.lang.String anUrl, java.lang.String anUser, java.lang.String aPassword) throws java.sql.SQLException
open
in interface ConnectionPool
anUrl
- A database url of the form jdbc:subprotocol:subname
.anUser
- The database user on whose behalf the connections will be made.aPassword
- The user's password.
java.sql.SQLException
public void open(java.lang.String aDriverClass, java.lang.String anUrl, java.lang.String anUser, java.lang.String aPassword) throws java.sql.SQLException
open
in interface ConnectionPool
aDriverClass
- Fully qualified name for the JDBC driver.anUrl
- A database url of the form jdbc:subprotocol:subname
.anUser
- The database user on whose behalf the connections will be made.aPassword
- The user's password.
java.sql.SQLException
public java.sql.Connection borrowConnection() throws java.sql.SQLException
borrowConnection
in interface ConnectionPool
java.sql.SQLException
public void returnConnection(java.sql.Connection aConnection) throws java.sql.SQLException
returnConnection
in interface ConnectionPool
aConnection
- A connection previously borrowed from the database.
java.sql.SQLException
public void close() throws java.sql.SQLException
close
in interface ConnectionPool
java.sql.SQLException
public boolean isOpen()
isOpen
in interface ConnectionPool
true
if the pool is open; false
otherwise.protected void finalize() throws java.lang.Throwable
java.lang.Throwable
public ConnectionPoolInfo getPoolInfo()
getPoolInfo
in interface ConnectionPool
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |