iiitToolkit 1.0

de.iiit.jdbc
Class JdbcConnectionPool

java.lang.Object
  |
  +--de.iiit.jdbc.JdbcConnectionPool

public class JdbcConnectionPool
extends Object

To be used as an pooled replacement of java.sql.connection.

Version:
$Revision: 1.9 $ $Date: 2003/04/02 09:25:08 $

Constructor Summary
JdbcConnectionPool(String url, String user, String password)
          Creates a pool prepared to connect to the given database URL.
JdbcConnectionPool(String url, String user, String password, int connections)
          Creates a pool prepared to connect to the given database URL and opens pre-defined connectios for later use.
 
Method Summary
 JdbcStatement createStatement()
          Creates a Statement object for sending SQL statements to the database.
protected  void destroyConnection(JdbcConnection connection)
          Remove the connection from the pool of busy ones but do not move it to free ones.
 JdbcDatabaseMetaData getMetaData()
          Retrieves a JdbcDatabaseMetaData object that contains metadata about the database to which this JdbcConnectionPool object represents a connection.
 JdbcPreparedStatement prepareStatement(String sql)
          Creates a PreparedStatement object for sending parameterized SQL statements to the database.
protected  void releaseConnection(JdbcConnection connection)
          marks the connection as free and moves it into the pool of free connections.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcConnectionPool

public JdbcConnectionPool(String url,
                          String user,
                          String password)
Creates a pool prepared to connect to the given database URL.

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

JdbcConnectionPool

public JdbcConnectionPool(String url,
                          String user,
                          String password,
                          int connections)
Creates a pool prepared to connect to the given database URL and opens pre-defined connectios for later use.

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
connections - then number of connections to open
Method Detail

createStatement

public JdbcStatement createStatement()
                              throws JdbcException
Creates a Statement object for sending SQL statements to the database.

Returns:
a new default JdbcStatement object
Throws:
JdbcException - if a database access error occurs

prepareStatement

public JdbcPreparedStatement prepareStatement(String sql)
                                       throws JdbcException
Creates a PreparedStatement object for sending parameterized SQL statements to the database.

Parameters:
sql - an SQL statement that may contain one or more '?' IN parameter placeholders
Returns:
a new default JdbcPreparedStatement object containing the pre-compiled SQL statement
Throws:
JdbcException - if a database access error occurs

getMetaData

public JdbcDatabaseMetaData getMetaData()
                                 throws JdbcException
Retrieves a JdbcDatabaseMetaData object that contains metadata about the database to which this JdbcConnectionPool object represents a connection.

Returns:
a DatabaseMetaData object for this Connection object
Throws:
JdbcException - if a database access error occurs

releaseConnection

protected void releaseConnection(JdbcConnection connection)
marks the connection as free and moves it into the pool of free connections.

Parameters:
connection - The JdbcConnection to release

destroyConnection

protected void destroyConnection(JdbcConnection connection)
Remove the connection from the pool of busy ones but do not move it to free ones. This method is called by JdbcConnection.destroyConnection() in case on an error.

Parameters:
connection - the connection to remove.

iiitToolkit 1.0

Copyright © 2002, 2003 ingeneurbuero fuer innovative informationstechnik, Dipl.-Ing. Joerg Beckmann, Dortmund, Germany. All Rights Reserved.
See Copyright statement