import jaydebeapi
import os
import jpype
import pandas as pd
from credentials_getter import get_db2_credentials
class i5Connection:
def __init__(self, user, password):
if jpype.isJVMStarted():
print("already started!")
filepath_script = os.path.dirname(os.path.abspath(__file__))
ssl_trust_store_location = filepath_script + "/database/java-certs.jks"
jar = filepath_script + '/database/jt400.jar'
jvm_path = jpype.getDefaultJVMPath()
jpype.startJVM(jvm_path,
'-Djava.class.path=%s' % jar,
'-Djavax.net.ssl.trustStore=%s' % ssl_trust_store_location +
'-Djavax.net.ssl.trustStorePassword=pw')
connection_string = 'jdbc:as400://172.17.0.1/library'
print(connection_string)
self.conn = jaydebeapi.connect('com.ibm.as400.access.AS400JDBCDriver',
connection_string,
{'user': user,
'password': password,
'secure': 'true'},
filepath_script + '/database/jt400.jar')
现在我遇到以下错误消息:
jpype._jexception.java.sql.SQLExceptionPyRaisable: java.sql.SQLException: The application requester cannot establish the connection. (PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target)
如果我从startJVM调用中删除了trustStoreLocation,密码和jaydebeapi调用的安全参数,它将起作用(不加密) 谁能告诉我我做错了什么?我可能还没有找到好的ibm文档?
编辑:Ive找到了一种解决方法:我只是通过密钥工具How do I import an existing Java keystore (.jks) file into a Java installation?将证书手动保存到cacert中。 并不是真正的解决方案,但如果有人也被卡住,希望能有所帮助...
答案 0 :(得分:0)
这不是 JayDeBeApi 解决方案,但我能够在 Mac 和 Windows 上使用 Python 通过加密连接 using this solution 连接到 HANA。