Databases Reference
In-Depth Information
Here are some facts about the ODBC connection pool model as defined in
the ODBC specification:
•
The Driver Manager maintains the connection pool.
•
Connection pooling is enabled by calling
SQLSetEnvAttr
to set the
SQL_ATTR_CONNECTION_POOLING
environment attribute. This environment
attribute can be set to associate a single pool either with each driver used by
an application or with each environment configured for an application
(which is typically only one).
•
When the application calls either
SQLConnect
or
SQLDriverConnect
,a con-
nection is used from the pool
if
a connection with the arguments passed by
the ODBC call can be matched with a connection in the pool. If not, a new
connection is established and placed in the pool when physically closed.
•
When the application calls
SQLDisconnect
, the connection is returned to
the pool.
•
The pool grows dynamically as applications use it; it is limited only by mem-
ory constraints and licensing limits on the server.
•
If a connection is inactive for a specified period, it is removed from the pool.
You can define the following attributes of a connection pool, which helps you
configure a pool for optimal performance:
•
Connection pooling timeout, which is set in the ODBC Administrator, is the
amount of time that connections remain in the pool before being removed.
•
Connection pool one per driver, which is set in your application. If your
application works with many drivers and few environments, using this con-
figuration may be optimal because fewer comparisons may be required to
find the correct connection. For example, the application creates one envi-
ronment handle (
henv
). On
henv
, the application connects to a Sybase driver
and to an Oracle driver. With this configuration, a pool will exist for connec-
tions to the Sybase driver, and a second pool will exist for connections to the
Oracle driver.
•
Connection pool one per environment, which is set in your application. If
your application works with many environments and a few drivers, using
this configuration may be optimal because fewer comparisons may be
required. For example, the application creates two environment handles
(
henv1
and
henv2
). On
henv1
, the application connects to a Sybase driver
and a Microsoft SQL Server driver. On
henv2
, it connects to an Oracle driver
and a DB2 driver. With this configuration, a pool will exist for
henv1
that has