This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I want to rescue a question that I found in the forum but never got answered, and I hope that somebody can give me any tip.
Thanks in advance.
Reed Peters wrote:
I am working on an app that will call AS400 RPG programs and commands. I got it all working fine, but I don't quite understand the AS400ConnectionPool class methods.
Right now I am creating an AS400 object, setting the parms, calling an RPG program, then disconnecting from the AS400 object (service). All works fine, however, I want to maximize throughput so I believe I want to get my AS400 object from a pool of AS400 objects managed by the AS400ConnectionPool class.
What I don't understand is how best to initialize the AS400ConnectionPool. Here's some IBM documentation about it: ----------------------------------------------- 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:
the maximum number of connections that can be given out by a pool the maximum lifetime of a connection the maximum inactivity time of a connection 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. --------------------------------------------- If I setup a connection pool using the AS400ConnectionPool methods what is the "scope" of the connection pool? Is it just for my application or is it for the entire server (web container)?
Is there a WAS administrative way of setting up the connection pool outside of my java application? Maybe something similar to the JDBC data source setup in the WAS admin application.
I hate to "hard code" these administrative functions in my java servlets.
Finally, if I just create a connection pool using the default settings and am very careful to always return my AS400 objects back to the pool when I am done with them, will everything kind of take care of themselves over time as the number of available objects plateaus out at some balanced number for the amount of work being done? (did that make sense?)