ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahh_5.4.0.1/connectionpool.htm

76 lines
5.2 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Connection pooling" />
<meta name="abstract" content="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." />
<meta name="description" content="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." />
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="connectionpool" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Connection pooling</title>
</head>
<body id="connectionpool"><a name="connectionpool"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Connection pooling</h1>
<div><p>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.</p>
<div class="section"><p>The <a href="javadoc/com/ibm/as400/access/AS400ConnectionPool.html#NAVBAR_TOP"> AS400ConnectionPool</a> class manages a pool of <a href="as400obj.htm#as400obj">AS400</a>
objects. The <a href="jdbcconnpool.htm#jdbcconnpool">AS400JDBCConnectionPool</a> class
represents a pool of AS400JDBCConnections that are available for use by a Java™ program
as part of IBM<sup>®</sup> 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.</p>
<p>A connection pool of either
type keeps track of the number of connections it creates. Using methods inherited
from <a href="javadoc/com/ibm/as400/access/ConnectionPool.html#NAVBAR_TOP"> ConnectionPool</a>, you can set several connection pool
properties, including:</p>
<ul><li>the <a href="javadoc/com/ibm/as400/access/ConnectionPool.html#SETMAXCONNECTIONS(INT)"> maximum number of connections</a> that can be given out
by a pool</li>
<li>the <a href="javadoc/com/ibm/as400/access/ConnectionPool.html#SETMAXLIFETIME(LONG)"> maximum lifetime</a> of a connection</li>
<li>the <a href="javadoc/com/ibm/as400/access/ConnectionPool.html#SETMAXINACTIVITY(LONG)"> maximum inactivity time</a> of a connection</li>
</ul>
<p>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 <a href="javadoc/com/ibm/as400/access/AS400ConnectionPool.html#FILL(JAVA.LANG.STRING, JAVA.LANG.STRING, JAVA.LANG.STRING, INT, INT)">filling the pool with active (preconnected) connections</a>.
Instead of creating new connections, you can use a connection pool to easily
retrieve, use, return, and reuse the connection objects.</p>
<p>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 <a href="javadoc/com/ibm/as400/access/AS400.html#FIELD_SUMMARY">constants from the AS400 class</a> (FILE, PRINT, COMMAND,
and so on).</p>
<p>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.</p>
<p>See <a href="mngcon.htm#mngcon">managing connections</a> for
more information about managing when a connection to the iSeries is
opened when using the AS400ConnectionPool classes.</p>
</div>
<div class="section"><h4 class="sectiontitle">Example: Using AS400ConnectionPool</h4><p><a href="connectpoolexample.htm#connectpoolexample">Example: Using AS400ConnectionPool</a> shows
how to reuse AS400 objects.</p>
</div>
</div>
</body>
</html>