连接到DB2数据库:[unixODBC] [驱动程序管理器] SQL_HANDLE_HENV上驱动程序的SQLAllocHandle失败 [英] connecting to DB2 database:[unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed

查看:977
本文介绍了连接到DB2数据库:[unixODBC] [驱动程序管理器] SQL_HANDLE_HENV上驱动程序的SQLAllocHandle失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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跟踪的代码段:

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.

推荐答案

根据此

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

原因

DB2®Universal Database™(DB2®)引入的新安全性功能 UDB)版本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.

或者,有许多线程(例如>巨大连接到DB2数据库时出现问题),这建议设置DB2INSTANCE环境变量以与您的odbc.ini文件中有关DSN的实例设置匹配,例如

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] [驱动程序管理器] SQL_HANDLE_HENV上驱动程序的SQLAllocHandle失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆