How do I get connection pooling working on a PHP-C

2020-07-23 03:11发布

I am trying to get connection pooling working using PHP/PDO with a UnixODBC driver called iSeries Access for Linux.

I do not set the PDO::ATTR_PERSISTENT in my PDO constructor as I want to use pooling and not persistence (I am in a PHP-CGI environment).

Using the "Connection Pooling" section of http://www.ibm.com/developerworks/systems/library/es-linux_bestpract.html I have placed

Pooling = Yes

in my odbc.ini and

CPTimeout = 600 

in my odbcinst.ini

However, it seems that the ODBC driver is not connection pooling because every page refresh generates the CPIAD09 related message of an incoming connection being made.

Here are my full ODBC configuration files:

==== odbc.ini ====
[AS400]
Description             = Production AS/400 Database
Driver                  = iSeries Access ODBC Driver
System                  = XXX.XXX.X.X
UserID                  = XXXXXXXX
Password                = XXXXXXXX
Naming                  = 0
DefaultLibraries        = USERLIB, BPCSF, ADV, WEB, RITAUSR
Database                =
ConnectionType          = 0
CommitMode              = 2
ExtendedDynamic         = 0
DefaultPkgLibrary       = QGPL
DefaultPackage          = A/DEFAULT(IBM),2,0,1,0,512
AllowDataCompression    = 1
LibraryView             = 0
AllowUnsupportedChar    = 0
ForceTranslation        = 0
Trace                   = 0
DSN                     = AS400
Pooling                 = Yes

and

==== odbcinst.ini ====
[iSeries Access ODBC Driver]
Description     = iSeries Access for Linux ODBC Driver
Driver          = /opt/ibm/iSeriesAccess/lib/libcwbodbc.so
Setup           = /opt/ibm/iSeriesAccess/lib/libcwbodbcs.so
NOTE1           = If using unixODBC 2.2.11 or later and you want the 32 and 64-bit ODBC drivers to share DSN's,
NOTE2           = the following Driver64/Setup64 keywords will provide that support.
Driver64        = /opt/ibm/iSeriesAccess/lib64/libcwbodbc.so
Setup64         = /opt/ibm/iSeriesAccess/lib64/libcwbodbcs.so
Threading       = 2
DontDLClose     = 1
UsageCount      = 1
CPTimeout       = 600

2条回答
啃猪蹄的小仙女
2楼-- · 2020-07-23 03:55

Increase the number of connection pool will always go on.

查看更多
贪生不怕死
3楼-- · 2020-07-23 03:57
Pooling         = Yes

This needs to go under [ODBC] in you odbcinst.ini and NOT your odbc.ini file

CPTimeout       = 600

Put this in your odbc.ini

查看更多
登录 后发表回答