如何将python连接到IBMDB2?

2024-06-20 15:18:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要以下python代码的帮助,我正在尝试将其连接到IBMDB2,但我遇到了这个错误。 操作错误:

ibm_db_dbi::OperationalError: Exception('[IBM][CLI Driver] SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "10.80.11.70". Communication function detecting the error: "connect". Protocol specific error code(s): "10061", "", "". SQLSTATE=08001\r SQLCODE=-30081')

下面是我的代码

import ibm_db_dbi as db

conn=db.connect("DATABASE=xxxx;HOSTNAME=xxxxxx;PORT:5950;PROTOCOL=TCPIP;UID=user;PWD=password;","","")

for t in conn.tables():
    print(t) ```

Tags: the代码dbconnect错误errorconnibm
1条回答
网友
1楼 · 发布于 2024-06-20 15:18:22

我猜10.80.11.70是db2服务器的IP

接收SQL30081N的几个原因。您的案例是TCP/IP协议错误。这不是db2的问题。 您将获得10061,这是连接被拒绝。 看看这篇文章,并确保其中描述了什么。 https://www.ibm.com/support/pages/sql30081n-tcpip-communication-errors

您还可以检查防火墙设置

相关问题 更多 >