as400 I 系列 JDBC 连接

问题描述 投票:0回答:1

我一直在尝试使用 JDBC 连接 as400(IBM DB2 i 系列)服务器,但是我编写的代码既没有给出任何异常,也没有打印任何内容。如果我做错了什么或需要更改任何服务器端配置,任何人都可以帮忙吗?

import jaydebeapi
import os
import configparser

class IbmDb2(object):

        def __init__(self):
            
            print("Initializing...")
            self.thisfolder = os.path.dirname(os.path.abspath(os.path.join(__file__, "..")))
            self.configfile = os.path.join(self.thisfolder, 'config', 'config.ini')
            self.config = configparser.ConfigParser()
            self.config_read = self.config.read(self.configfile)
            
            self.driver = self.config.get('DRIVER', 'driver')
            self.user = self.config.get('USER', 'user')
            self.password = self.config.get('PASSWORD', 'password')
            
            # Load the Netsuite JDBC driver
            self.jar_path = os.path.join(self.thisfolder, 'jars', "jt400.jar")
            print(f"JAR Path: {self.jar_path}")
            self.conn_str = "jdbc:as400://XX.XX.XX.XX:9099/WM410BASD"
            
            self.connection = jaydebeapi.connect(self.driver, self.conn_str, [self.user, self.password] , 'C:/google_analytics_data/db2-to-bq/jars/jt400.jar', )
            print(self.connection)
            print("Connection success")

            # Establish the connection
            self.cursor = self.connection.cursor()
            self.cursor.execute('select count(*) from WM410BASD.PHPICK00')
            results = self.cursor.fetchall()
            print(results)
            self.connection.close()

if __name__ == "__main__":
    db2data = IbmDb2()
python db2 ibm-midrange
1个回答
0
投票

检查您的系列中是否有 CPF9898 消息。它们指示授权错误。 您应该在 QSECOFR 或用户日志中找到它们。

© www.soinside.com 2019 - 2024. All rights reserved.