Access IBM DVM(Data Virtualization Manager) from linux Unbuntu vm using Python

240 Views Asked by At

I am trying to access IBM DVM(Data Virtualization Manager) from linux Unbuntu vm using Python.

I have installed JAVA on the unbuntu machine: java -version

openjdk version "1.8.0_362" OpenJDK Runtime Environment (build 1.8.0_362-b08) OpenJDK 64-Bit Server VM (build 25.362-b08, mixed mode)

I have also installed JayDeBeAPI: pip install JayDeBeApi

Installing collected packages: packaging, JPype1, JayDeBeApi Successfully installed JPype1-1.4.1 JayDeBeApi-1.2.3 packaging-23.0

From IBM website i have download the DVM-JDBC3.1 driver

https://ak-delivery04-mul.dhe.ibm.com/sar/CMA/IMA/0bb4c/0/dvm-jdbc-3.1.202303130554.zip Unzipped to /opt/dvm-jdbc-3.1.202303130554.

I have also set the class path: echo $CLASSPATH

/opt/dv-jdbc-3.1.202303130554:/opt/dv-jdbc-3.1.202303130554/dv-jdbc-3.1.202303130554.jar:

Now I am trying to Run the following python code to connect to DVM

import jpype

import jaydebeapi

dvm_driver_path = "/opt/dv-jdbc-3.1.202303130554/dv-jdbc-3.1.202303130554.jar"

jpype.addClassPath('/opt/dv-jdbc-3.1.202303130554/dv-jdbc-3.1.202303130554.jar') jpype.startJVM(jpype.getDefaultJVMPath(), "-Djava.class.path=%s" % ('/opt/dv-jdbc-3.1.202303130554/dv-jdbc-3.1.202303130554.jar'))

conn = jaydebeapi.connect('com.rs.jdbc.dv.DvDriver.class', 'jdbc:dv://###:##/###', {'user': '#####', 'password': '####'}, '/opt/dv-jdbc-3.1.202303130554/dv-jdbc-3.1.202303130554.jar')

if (conn): print('Connected') else: print('Failed to connect')

but i am getting the following error: python3 dvm-jdbc.py Traceback (most recent call last): File "/opt/dv-jdbc-3.1.202303130554/dvm-jdbc.py", line 26, in conn = jaydebeapi.connect('com.rs.jdbc.dv.DvDriver.class', File "/home/sanika/.local/lib/python3.10/site-packages/jaydebeapi/init.py", line 412, in connect jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs) File "/home/sanika/.local/lib/python3.10/site-packages/jaydebeapi/init.py", line 221, in _jdbc_connect_jpype jpype.JClass(jclassname) File "/home/sanika/.local/lib/python3.10/site-packages/jpype/_jclass.py", line 99, in new return _jpype._getClass(jc) TypeError: Class com.rs.jdbc.dv.DvDriver.class is not found

Is my driver class wrong? If so what is the correct one?

1

There are 1 best solutions below

2
On

The correct class name should be 'com.rs.jdbc.dv.DvDriver' , so your connection line should be

conn = jaydebeapi.connect('com.rs.jdbc.dv.DvDriver', 'jdbc:dv://###:##/###', {'user': '#####', 'password': '####'}, '/opt/dv-jdbc-3.1.202303130554/dv-jdbc-3.1.202303130554.jar')

also make sure the path to the JDBC driver is correct, because you are mentioning /opt/dvm-jdbc-3.1.202303130554 and /opt/dv-jdbc-3.1.202303130554 in your code.