1

I am trying to connect to DB2 from Python on my Mac M1. Unfortunately, I have no control over the python version (Python 3.10.6) installed on the Mac. I tried to follow the instructions on Connect to DB2 via JayDeBeApi JDBC in Python to set up JDBC connection but failing with error

FileNotFoundError: [Errno 2] JVM DLL not found: /Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home/lib/libjli.dylib

Though the file libjle.dylib exists in the above folder, the error pops up. I have tried trying to find a solution online with no luck.

I have connected to the same DB2 database through DBeaver on my Mac, but not able to through python.

Note, I don't have admin privileges to install/re-install but can only download packages from a repo.

Any pointers would really be very helpful

I tried the following code

import jaydebeapi
import jpype

jar = '/Users/JARFILES/jcc-11.5.7.0.jar' # location of the jdbc driver jar which is used by DBEaver
args='-Djava.class.path=%s' % jar
jvm = jpype.getDefaultJVMPath()
jpype.startJVM(jvm, args)

jaydebeapi.connect(
'com.ibm.db2.jcc.DB2Driver', 
['jdbc:db2://server:port/database','myusername','mypassword']
)
john_sab1
  • 13
  • 3
  • Have you tried using a pure python driver, such as `pydrda`? – Selcuk Jan 30 '23 at 03:44
  • @Selcuk, just tried now but getting UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 31: invalid start byte error... followed instructions from https://github.com/nakagami/pydrda – john_sab1 Jan 30 '23 at 03:55

0 Answers0