I need to create a connection to a DB2 database in an IBM i system, using Python library jaydebeapi, with the following instruction:
import sys
import jaydebeapi
import os
try:
conn = jaydebeapi.connect("com.ibm.as400.access.AS400JDBCDriver",
f"jdbc:as400://{hostname};naming=system;libraries=*LIBL;errors=full;date format=iso;time format=iso;translate binary=true;data truncation=false",
[user, password],
f"{dirname}\jt400-20.0.0.jar")
except jaydebeapi.Error as e:
print(f"Error connecting to DB2 Platform: {e}")
sys.exit(1)
print(f"Connection to DB2 was successful")
The script ends with no errors, but it prints nothing on console. Debugging the script I found the instruction that does nothing is the following:
_jpype.startup(jvmpath, tuple(args), ignoreUnrecognized, convertStrings, interrupt)
This instruction is in the _core.py module within jpype library.
Debugging the script with pdb shows the following:
(.venv) C:\scripts>python carga.py
jvmpath: C:\Program Files\Java\jdk1.8.0_121\jre\bin\server\jvm.dll, tuple(args): ('-Djava.class.path=C:\\scripts\\jt400-20.0.0.jar',)
> C:\scripts\.venv\lib\site-packages\jpype\_core.py(227)startJVM()
-> _jpype.startup(jvmpath, tuple(args), ignoreUnrecognized, convertStrings, interrupt)
(Pdb) s
(.venv) C:\scripts>
And that’s it, no error, no message, nothing.
I was unable to find startup function in any of the libraries I have installed.
I checked that the class com.ibm.as400.access.AS400JDBCDriver is contained within the given jar jt400-20.0.0.jar:
I’m using Python 3.11.4 win-64, and java 1.8.0_121 win-64
The problem seems related to the loading of java. But did you try with jt400-20.0.0-java8.jar ?
it is specifically for java 8.