连接到 DB2 数据库:[unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed [英] connecting to DB2 database:[unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed
问题描述
odbc.ini:
[DEFAULT]
Driver = DB2
[abc]
Driver = DB2
[dsn_test1]
DESCRIPTION = Connection to DB2
Driver = db2
odbcinst.ini:
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
$ ./isql abc
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
从 db2 驱动程序连接时,出现以下错误:
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
下面是odbc trace的片段:
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]
google了很多根本原因,dint帮助很大,请提供一些解决这个问题的指针.它是一个 32 位 linux 机器,也有 32 位 db 驱动程序.
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.
推荐答案
据此IBM 支持页面,一个 IM004 SQLState on SQLAllocHandle 与新的安全特性相关.
According to this IBM Support page, an IM004 SQLState on SQLAllocHandle relates to the new security feature.
DB2® Universal Database™(DB2UDB) 8.2 版禁止用户使用数据库,除非他们属于 Windows® 组 DB2ADMNS 或 DB2USERS.
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.
将用户 ID(用于执行应用程序的用户 ID)添加到任一DB2ADMNS 或 DB2USERS 组.请参考相关"下的链接信息"(如下),了解如何完成此操作的说明.
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.
或者,有许多线程(例如 Huge连接到 DB2 数据库的问题)建议设置 DB2INSTANCE
环境变量以匹配相关 DSN 的 odbc.ini
文件中的实例设置,例如
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
这篇关于连接到 DB2 数据库:[unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!