Use connection pools to share connections and manage sets (pools) of connections to an iSeries™ server. For example, an application can retrieve a connection from a pool, use it, then return it to the pool for reuse.
The AS400ConnectionPool class manages a pool of AS400 objects. The AS400JDBCConnectionPool class represents a pool of AS400JDBCConnections that are available for use by a Java™ program as part of IBM® Toolbox for Java support for the JDBC 2.0 Optional Package API. The JDBC ConnectionPool interface is also supported in the JDBC 3.0 API, which is bundled with the Java 2 Platform, Standard Edition, version 1.4.
A connection pool of either type keeps track of the number of connections it creates. Using methods inherited from ConnectionPool, you can set several connection pool properties, including:
In terms of performance, connecting to the server is an expensive operation. Using connection pools can improve performance by avoiding repeated connection times. For example, create connections when you create the connection pool by filling the pool with active (preconnected) connections. Instead of creating new connections, you can use a connection pool to easily retrieve, use, return, and reuse the connection objects.
Retrieve a connection using an AS400ConnectionPool by specifying the system name, user id, the password, and (optionally) the service. To specify the service to which you want to connect, use constants from the AS400 class (FILE, PRINT, COMMAND, and so on).
After retrieving and using the connection, applications return connections to the pool. It is the responsibility of each application to return connections to the pool for reuse. When connections are not returned to the pool, the connection pool continues to grow in size and connections are not reused.
See managing connections for more information about managing when a connection to the iSeries is opened when using the AS400ConnectionPool classes.
Example: Using AS400ConnectionPool shows how to reuse AS400 objects.