IBM Support

SQLSTATE IM004, SQLAllocHandle on SQL_HANDLE_ENV failed, when connecting via an ODBC application

Question & Answer


Question

This document provides troubleshooting information for the situation where you are attempting to connect to a DB2 UDB database within an ODBC application and receive a message such as the following: SQLSTATE = IM004 Native error = 0 Msg:[Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle on SQL_HANDLE_ENV failed.

Cause

The new security features introduced in DB2® Universal Database™ (DB2 UDB) Version 8.2 prevent users from using the database unless they belong to the Windows® groups DB2ADMNS or DB2USERS.

Diagnosis Details
In this situation, the message may not appear within CLI traces and an ODBC trace may just indicate that the SQLConnectW() call fails.

Answer

Add the userid (the one used to execute the application) to either the DB2ADMNS or DB2USERS group. Please refer to the link under "Related Information" (below) for instructions on how to accomplish this.

As of DB2 UDB Version 8.1 FixPak 10 (also known as DB2 UDB Version 8.2 FixPak 3), a clearer error message will be returned in situations where enhanced security have been enabled and a userid does not meet these qualifications.

This is accomplished via APAR JR20697 with the message below:



SQL1092N "<authorization-ID>" does not have the authority to perform the requested command.

[{"Product":{"code":"SSEPGG","label":"DB2 for Linux- UNIX and Windows"},"Business Unit":{"code":"BU001","label":"Analytics Private Cloud"},"Component":"Database Objects\/Config - Authorization\/Privilege","Platform":[{"code":"PF033","label":"Windows"}],"Version":"9.7;9.5;9.1;8.2;10.1;10.5;11.1","Edition":""}]

Document Information

Modified date:
16 June 2018

UID

swg21229860