connecting to DB2 database:[unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed

牧云@^-^@ 提交于 2019-12-23 16:51:45

问题


odbc.ini:

[DEFAULT]
Driver          = DB2
[abc]
Driver          = DB2
[dsn_test1]
DESCRIPTION = Connection to DB2
Driver          = db2

odbcinst.ini:

[DB2]
Description = DB2 Driver
Driver = /home/user/sqllib/lib/libdb2.so
fileusage=1
dontdlclose=1

[ODBC]
Trace=1
TraceFile=/home/user/sqllib/trace.out

db2cli.ini

[abc]
hostname="hostname"
pwd="passwd"
port="port"
PROTOCOL=TCPIP
database="dbname"
uid="uid"

$ ./isql abc

+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+

while connecting from db2 driver,below error is coming:

Connection attempt for data source name "abc":
===============================================================================
ODBC Driver Manager Path: /home/user/sqllib/odbclib/lib/libodbc.so

[FAILED]: [unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV 
failed

Below is the snippet of odbc trace:

[ODBC][23419][1403783774.660159][SQLConnect.c][1380]Error: IM004
[ODBC][23419][1403783774.660223][SQLError.c][434]
    Entry:
        Connection = 0x81aaac8
        SQLState = 0xffff9593
        Native = 0xffff9684
        Message Text = 0xffff8d93
        Buffer Length = 1024
        Text Len Ptr = 0xffff95bc
[ODBC][23419][1403783774.660260][SQLError.c][471]
    Exit:[SQL_SUCCESS]
        SQLState = IM004
        Native = 0xffff9684 -> 0
        Message Text = [[unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed]

Googled a lot for root-cause,dint helped much,please provide some pointer to solve this. its a 32 bit linux machine having 32 bit db driver as well.


回答1:


According to this IBM Support page, an IM004 SQLState on SQLAllocHandle relates to the new security feature.

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.

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.

Alternatively, there are a number of threads (e.g. Huge problems connecting to a DB2 database) which suggest setting the DB2INSTANCE environment variable to match the instance setting in your odbc.ini file for the DSN concerned, e.g.

export DB2INSTANCE=db2inst1
isql -v FS01DB2


来源:https://stackoverflow.com/questions/24444326/connecting-to-db2-databaseunixodbcdriver-managerdrivers-sqlallochandle-on

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!