This problem can be resolved by adding the userid to the Windows groups DB2ADMNS or DB2USERS.
This is described at https://www.ibm.com/support/pages/sqlstate-im004-sqlallochandle-sqlhandleenv-failed-when-connecting-odbc-application
To add a user to the DB2ADMNS or DB2USERS group, follow the instructions at https://www.ibm.com/support/knowledgecenter/en/SSEPGG_9.7.0/com.ibm.db2.luw.qb.server.doc/doc/t0011930.html
Note: once you have added a user to a group, for the changes to come into effect the user must logoff Windows then log back on again
Other causes of this problem have been:
This problem can be avoided by running AQT using Run as Administrator.