All Packages Class Hierarchy This Package Previous Next Index
Class nl.nmg.sql.PoolDriverManager
java.lang.Object
|
+----nl.nmg.sql.PoolDriverManager
- public class PoolDriverManager
- extends Object
- implements Runnable
The PoolDriverManager keeps a pool of connections. If a
connection is requested, the pool is checked for a similar
free connection. If none can be found, a new connection is made.
The DriverManager.getConnection() methods have been
reimplemented by PoolDriverManager, allowing you to use
it like this:
conn = PoolDriverManager.getConnection("jdbc:odbc:SampleTable");
A connection from the pool is considered in use, until its
close() method is called. This does not actually close the
connection, but returns the connection to the pool instead.
(The reference used to call close() should not be used after
that; it will refer to the connection in the pool and use of
this connection will result in unpredictable behaviour.)
When a connection is returned to the pool, any uncommited
changes are rolled back. Persistent changes made to the
connection through the Connection interface are undone,
but persistent changes made through SQL commands are not.
If a connection in the pool has not been used for 5 minutes
it is closed and removed from the pool. A "pool-cleaner" thread
checks the state of the connections in the pool every 30 seconds.
- See Also:
- DriverManager, PoolConnection, PoolDriver
-
getConnection(String)
- Attempt to establish a connection to the given database URL.
-
getConnection(String, Properties)
- Attempt to establish a connection to the given database URL.
-
getConnection(String, String, String)
- Attempt to establish a connection to the given database URL.
-
run()
- The pool cleaner thread.
getConnection
public static Connection getConnection(String url,
Properties info) throws SQLException
- Attempt to establish a connection to the given database URL.
The PoolDriverManager attempts to get a connection from the
pool and calls DriverManager.getConnection() if that fails.
- Parameters:
- url - a database url of the form jdbc:subprotocol:subname
- info - a list of arbitrary string tag/value pairs as
connection arguments; normally at least a "user" and
"password" property should be included
- Returns:
- a Connection to the URL
- Throws: SQLException
- if a database-access error occurs.
getConnection
public static Connection getConnection(String url,
String user,
String password) throws SQLException
- Attempt to establish a connection to the given database URL.
The PoolDriverManager attempts to get a connection from the
pool and calls DriverManager.getConnection() if that fails.
- Parameters:
- url - a database url of the form jdbc:subprotocol:subname
- user - the database user on whose behalf the Connection is being made
- password - the user's password
- Returns:
- a Connection to the URL
- Throws: SQLException
- if a database-access error occurs.
getConnection
public static Connection getConnection(String url) throws SQLException
- Attempt to establish a connection to the given database URL.
The PoolDriverManager attempts to get a connection from the
pool and calls DriverManager.getConnection() if that fails.
- Parameters:
- url - a database url of the form jdbc:subprotocol:subname
- Returns:
- a Connection to the URL
- Throws: SQLException
- if a database-access error occurs.
run
public void run()
- The pool cleaner thread. Checks for connections that have not been used
for more than 5 minutes, every 30 seconds.
All Packages Class Hierarchy This Package Previous Next Index