Use a connection pool to share and manage connections to an iSeries server.
In terms of performance, connecting to the server is an expensive operation. Using a connection pool can increase performance by enabling you to use, reuse, and share existing connections instead of repeatedly connecting and disconnecting.
The AS400ConnectionPool class manages a pool of AS400 objects. The AS400JDBCConnectionPool class represents a pool of AS/400JDBCConnections that are available for use by a Java program.
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:
Retrieve a connection using an AS400ConnectionPool by specifying the system name, user id, the password (optional), and the service (optional).
Return connections to an AS400ConnectionPool by using the returnConnectionToPool() method.
Note: When connections are not returned to the pool, the connection pool continues to grow in size and connections are not reused.
Ensure that the time used to create connections occurs when the pool is created by filling the pool with active (preconnected) connections. A user can then retrieve a connection from the pool, use the connection in an application, and return the connection to the pool for reuse. Note that it is the responsibility of each application to return connections to the pool for reuse.
See managing connections for more information about managing when a connection to the iSeries is opened when using the AS400ConnectionPool classes.
Example: Using an AS400ConnectionPool to reuse AS400
objects