The AS400JDBCConnectionPool class represents a pool of AS/400JDBCConnections that are available for use by a Java program.
Set either the URL property (Where is the method for this?? - JG) or the dataSourceName property to specify how you want to establish the database connection. Set the command property (Where is the method for this?? - JG) to specify how to create a PreparedStatement.
You can not change the connection pool data source after you have requested a connection and the pool is in use. To reset the connection pool data source, first call close() on the pool.
Set properties on the pool by using methods inherited from ConnectionPool. Some of the properties that you can set include:
You can also register AS400JDBCConnectionPool objects by using a Java Naming and Directory Interface (JNDI) service provider. For more information on JNDI service providers, see AS/400 Toolbox for Java reference links.
The following example gets a connection pool data source from JNDI and uses it to create a connection pool with 10 connections:
// Obtain an AS400JDBCConnectionPoolDataSource object from JNDI (assumes JNDI environment is set). 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();