开发者

DB2 connection string problem

开发者 https://www.devze.com 2023-03-13 01:29 出处:网络
I have the following code: import pyodbc cnxn = pyodbc.connect(\'DRIVER={IBM DB2 ODBC DRIVER};DATABASE=TDB2;UID=username;PWD=password\')

I have the following code:

import pyodbc
cnxn = pyodbc.connect('DRIVER={IBM DB2 ODBC DRIVER};DATABASE=TDB2;UID=username;PWD=password')

I get the error message SQLSTATE=42705, which means that it cannot reach the database.

When I connect to DB2 using AQT, it states that the Database Name is DB2, Data Source Name is TDB2, DBALIAS=TDB2, ODBC driver is DB2CLI.DLL. Inside the database, I have some kind of "containers", which are listed in the category of "Database Objects", the containers contain Tables, and I believe that I need to specify this in my connection string as well.

I am completely confused about this. 开发者_StackOverflow社区I do not even understand how AQT can connect to the database, without me providing an IP address, nor port number.


The solution was to remove the DATABASE=TDB2 and replace it with DBALIAS=TDB2.

0

精彩评论

暂无评论...
验证码 换一张
取 消