|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--com.ibm.as400.access.ConnectionPool
|
+--com.ibm.as400.access.AS400JDBCConnectionPool
The AS400JDBCConnectionPool class represents a pool of AS/400 or iSeries JDBC connections that are available for use by a Java program.
Note: AS400JDBCConnectionPool objects are threadsafe.
The following example creates a connection pool with 10 connections.
// Obtain an AS400JDBCConnectionPoolDataSource object from JNDI. Context context = new InitialContext(environment); AS400JDBCConnectionPoolDataSource datasource = (AS400JDBCConnectionPoolDataSource)context.lookup("jdbc/myDatabase"); // Create an AS400JDBCConnectionPool object. AS400JDBCConnectionPool pool = new AS400JDBCConnectionPool(datasource); // Adds 10 connections to the pool that can be used by the application (creates the physical database connections based on the data source). pool.fill(10); // Get a handle to a database connection from the pool. Connection connection = pool.getConnection(); ... Perform miscellenous queries/updates on the database. // Close the connection handle to return it to the pool. connection.close(); ... Application works with some more connections from the pool. // Close the pool to release all resources. pool.close();
| Constructor Summary | |
AS400JDBCConnectionPool()
Constructs a default AS400JDBCConnectionPool object. |
|
AS400JDBCConnectionPool(AS400JDBCConnectionPoolDataSource dataSource)
Constructs an AS400JDBCConnectionPool object with the specified dataSource. |
|
| Method Summary | |
void |
close()
Closes all the unused database connections in the pool. |
void |
fill(int numberOfConnections)
Fills the connection pool with the specified number of database connections. |
protected void |
finalize()
Closes the connection pool if not explicitly closed by the caller. |
int |
getActiveConnectionCount()
Returns the number of active connections the pool has created. |
int |
getAvailableConnectionCount()
Returns the number of available PooledConnections in the pool. |
java.sql.Connection |
getConnection()
Returns a connection from the pool. |
AS400JDBCConnectionPoolDataSource |
getDataSource()
Returns the data source used to make connections. |
boolean |
isClosed()
Indicates whether the connection pool is closed. |
void |
setDataSource(AS400JDBCConnectionPoolDataSource dataSource)
Sets the data source used to make connections. |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public AS400JDBCConnectionPool()
public AS400JDBCConnectionPool(AS400JDBCConnectionPoolDataSource dataSource)
dataSource - The AS400JDBCConnectionPoolDataSource object.| Method Detail |
public void close()
close in class ConnectionPoolcom.ibm.as400.access.ConnectionPoolConnectionPoolException - If a pool error occurs.
public void fill(int numberOfConnections)
throws ConnectionPoolException
numberOfConnections - The number of connections to add to the pool.ConnectionPoolException - If a database error occurs creating a connection for the pool.
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable - If an error occurs.public int getActiveConnectionCount()
public int getAvailableConnectionCount()
public java.sql.Connection getConnection()
throws ConnectionPoolException
ConnectionPoolException - If a database error occurs getting the connection.public AS400JDBCConnectionPoolDataSource getDataSource()
public boolean isClosed()
public void setDataSource(AS400JDBCConnectionPoolDataSource dataSource)
throws java.beans.PropertyVetoException
dataSource - The AS400JDBCConnectionPoolDataSource object.java.beans.PropertyVetoException - If a change is vetoed.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||