Friday, January 27, 2006

INFO: Frequently Asked Questions About ODBC Connection Pooling:


INFO: Frequently Asked Questions About ODBC Connection Pooling

This article was previously published under Q169470

SUMMARY

This article covers some of the most frequently asked questions about ODBC connection pooling.

MORE INFORMATION

1.Q. What is ODBC connection pooling?

A. Connection pooling is one the new features introduced in ODBC 3.0. Connection pooling enables an ODBC application to reuse a connection from a pool of connections. Once a connection has been created and placed in the pool, an ODBC application can reuse the same driver and the connection within the same shared environment (henv) without performing the complete connection process. However, a connection can never be reused between different henv or different drivers.
2.Q. Can I use connection pooling with 2.x ODBC drivers?

A. Connection pooling is implemented in the ODBC driver manager version 3.0 or later. The driver version does not matter.
3.Q. Can I enable connection pooling with the Microsoft Access driver because the connection pooling is implemented in the driver manager?

A. You can enable connection pooling for Microsoft Access driver. Microsoft Access uses Jet, and Jet is thread safe starting from Jet 4.0. From MDAC 2.1 and later, you can have connection pooling for Access ODBC driver.
4.Q. How do I enable connection pooling in an ODBC application?

A. An ODBC application can call SQLSetEnvAttr with the SQL_ATTR_CONNECTION_POOLING attribute to enable connection pooling. For more information about how to enable connection pooling in an ODBC application, please see the following article in the Microsoft Knowledge Base:
164221 (http://support.microsoft.com/kb/164221/EN-US/) How to Enable Connection Pooling in an ODBC Application
5.Q. How do I enable connection pooling if the application is written in Visual Basic?

A. A Visual Basic or ODBC application can call the SQLSetEnvAttr function to enable connection pooling. Connection pooling is a process-level attribute, so any subsequent connection made through the ODBC driver manager in the Visual Basic application will use connection pooling. A Visual Basic application can use the function declaration and code to enable connection pooling.
      Declare Function SQLSetEnvAttr Lib "odbc32.dll" (ByVal henv As Long,
ByVal Attribute As Long, ByVal Value As Long, ByVal StringLength As
Long) As Integer

' env attribute
Public Const SQL_ATTR_CONNECTION_POOLING = 201
Public Const SQL_ATTR_CP_MATCH = 202

' values for SQL_ATTR_CONNECTION_POOLING
Public Const SQL_CP_ONE_PER_DRIVER = 1
Public Const SQL_IS_UINTEGER = -5

nstatus = SQLSetEnvAttr(0, SQL_ATTR_CONNECTION_POOLING,
SQL_CP_ONE_PER_DRIVER, SQL_IS_UINTEGER)
SQLAllocEnv...
SQLAllocConnect...
SQLConnect...
SQLDisConnect...
SQLFreeConnect...
SQLFreeEnv...
For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:
237844 (http://support.microsoft.com/kb/237844/EN-US/) HOWTO: Enable ODBC Connection Pooling in VB ADO Application
228843 (http://support.microsoft.com/kb/228843/EN-US/) HOWTO: Implement Session Pooling from Visual Basic ADO Program

0 Comments:

Post a Comment

<< Home