As an object-oriented Java programming model, IBM Java Toolbox for I provides API-level communication support for Java applications to access IBM I data and resources. While the AS400 class represents the IBM Java Toolbox for I socket connection with IBM I, any behavior that relies on IBM Java Toolbox for I to manipulate IBM I data and resources is premised on communication with IBM I. In this sense, AS400 can be viewed as an access point for IBM i. The main objective of this article is to instruct readers how to use IBM Java Toolbox for I to optimize the connection with IBM I from the perspective of reusing IBM I connection object AS400. For a basic knowledge of IBM Java Toolbox for I, see another technical document "Toolbox for Java and Jtopen."
From the content, this article mainly divides into 5 parts. The 1th part mainly from the connection pool optimization angle, introduced IBM Java Toolbox for I to the IBM I Connection optimization, the 2nd part mainly from the reuse AS400 object's angle, introduced IBM Java Toolbox for I's optimization strategy The 3rd part is the combination of two optimization strategies of connection pooling and reuse AS400, and the 4th part is about optimizing the start and stop strategy of IBM I Connection; the 5th part is summary.
IBM Java Toolbox Connection Pooling optimization
In general, a habitual idea for optimizing communication connections is to use a connection pooling strategy to reduce the resource and time overhead associated with each server-side connection. IBM Java Toolbox For I provides a as400connectionpool class for creating and managing connection pooling, as shown in Figure I.
Figure 1. Working principle of connection pool
The As400connectionpool class works as follows:
Create IBM I connection pool object-as400connectionpool.
Set connection pool-related properties, such as the maximum number of connections.
Establish a certain number of pre-connections, known as idle connections.
For a server access request, a connection is obtained directly from the connection pool. If there are no idle connections in the connection pool object and the number of connections does not reach the maximum active connections, a new IBM I connection is created.