net.sf.jso.sql
Class NoPool

java.lang.Object
  extended bynet.sf.jso.sql.NoPool
All Implemented Interfaces:
ConnectionPool, ConnectionPoolInfo

public class NoPool
extends java.lang.Object
implements ConnectionPool, ConnectionPoolInfo

Manages a pool of database connections.


Constructor Summary
NoPool()
          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.
 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
 

Constructor Detail

NoPool

public NoPool()
       throws java.lang.IllegalArgumentException
Constructs the pool.

Method Detail

url

public java.lang.String url()
Returns the current database url.

Returns:
The current database url.

user

public java.lang.String user()
Returns the current database user.

Returns:
The current database user.

capacity

public int capacity()
Returns the maximum pool size.

Specified by:
capacity in interface ConnectionPoolInfo
Returns:
The maxmimum number of connections the pool is able to manage.

size

public int size()
Returns the current pool size.

Specified by:
size in interface ConnectionPoolInfo
Returns:
The number of connections the pool is managing.

idle

public int idle()
Returns the number of idle connections.

Specified by:
idle in interface ConnectionPoolInfo
Returns:
The number of idle connections.

inUse

public int inUse()
Returns the number of used connections.

Specified by:
inUse in interface ConnectionPoolInfo
Returns:
The number of used connections.

open

public void open(java.lang.String anUrl,
                 java.lang.String anUser,
                 java.lang.String aPassword)
          throws java.sql.SQLException
Opens the pool.

Specified by:
open in interface ConnectionPool
Parameters:
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.
Throws:
java.sql.SQLException

open

public void open(java.lang.String aDriverClass,
                 java.lang.String anUrl,
                 java.lang.String anUser,
                 java.lang.String aPassword)
          throws java.sql.SQLException
Opens the pool.

Specified by:
open in interface ConnectionPool
Parameters:
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.
Throws:
java.sql.SQLException

borrowConnection

public java.sql.Connection borrowConnection()
                                     throws java.sql.SQLException
Borrows a connection from the pool.

Specified by:
borrowConnection in interface ConnectionPool
Returns:
A connection to the database.
Throws:
java.sql.SQLException

returnConnection

public void returnConnection(java.sql.Connection aConnection)
                      throws java.sql.SQLException
Returns a connection to the pool.

Specified by:
returnConnection in interface ConnectionPool
Parameters:
aConnection - A connection previously borrowed from the database.
Throws:
java.sql.SQLException

close

public void close()
           throws java.sql.SQLException
Closes the pool. Closes all open connections, even those not returned to the pool.

Specified by:
close in interface ConnectionPool
Throws:
java.sql.SQLException

isOpen

public boolean isOpen()
Indicates if the pool is open.

Specified by:
isOpen in interface ConnectionPool
Returns:
true if the pool is open; false otherwise.

finalize

protected void finalize()
                 throws java.lang.Throwable
Cleans the pool before it's garbage collected.

Throws:
java.lang.Throwable

getPoolInfo

public ConnectionPoolInfo getPoolInfo()
Gets connection pool information.

Specified by:
getPoolInfo in interface ConnectionPool
Returns:
Information about the connection pool.