IBM Support

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

Technote (FAQ)


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.

Related information

Extended security installation restrictions (Windows)
APAR JR20697
Adding your user ID to the DB2ADMNS and DB2USERS

Document information

More support for: DB2 for Linux, UNIX and Windows
Database Objects/Config - Authorization/Privilege

Software version: 8.2, 9.1, 9.5, 9.7, 10.1, 10.5, 11.1

Operating system(s): Windows

Reference #: 1229860

Modified date: 19 June 2008