IBM Support

ODBC connection from Windows Db2 client failed with "SQLAllocHandle on SQL_HANDLE_ENV failed"

Troubleshooting


Problem

ODBC connection from Windows Db2 client failed like following
[IM004] [Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle on SQL_HANDLE_ENV failed.

Diagnosing The Problem

In db2trace output we can see
981         sqleInitApplicationEnvironment data [probe 30]
982         | pdLog exit
983         | sqloxult_app entry
984         | sqloxult_app exit
985         sqleInitApplicationEnvironment exit [rc = 0xFFFFEC73 = -5005]
986         sqloxult_app entry
987         sqloxult_app exit
988         SQLAllocHandle entry
989         | CLI_utlTraceInit entry
990         | | CLI_latRequestStatic entry
991         | | CLI_latRequestStatic data [probe 1]
992         | | CLI_latRequestStatic error [probe 2]
993         | | CLI_latRequestStatic exit [rc = 0xFFFFFFFF = -1]
994         | CLI_utlTraceInit exit
995         SQLAllocHandle data [probe 2]
996         SQLAllocHandle exit [rc = 0xFFFFFFFF = -1]

Resolving The Problem

This is usually because extended security is enabled on Windows, while the user running ODBC test is not in DB2ADMNS group.
Adding the user to DB2ADMNS group should solve this issue.
If extended security is enabled and later disabled by uninstall/reinstall, the error may be still there as Db2 files are not removed completely. Please follow these steps
1) drop instance/database if there is any
2) remove all the files related with Db2 (especially the DB2PATH and DB2INSTPROF defined in "db2set -all")
3) uninstall Db2
4) clean windows registries
5) reinstall Db2
6) test ODBC again

Document Location

Worldwide

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"ARM Category":[{"code":"a8m0z0000001gWCAAY","label":"Connectivity->ODBC"}],"ARM Case Number":"","Platform":[{"code":"PF033","label":"Windows"}],"Version":"All Version(s)","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
31 July 2020

UID

ibm16253149