You can translate the question and the replies:

Connection from Python to Denodo

Hello, I want to access data from denodo using python3. My code looks like the following: ``` import jaydebeapi hostname = '####################' port = '####' driver = 'com.denodo.vdp.jdbc.Driver' user = '#####' password = '#####' path = '/home/I011404/Denodo_Test/driver/jdbc/driver/jdbc/denodo-vdp-jdbcdriver.jar' url = 'jdbc:vdb://'+hostname+':'+port+'/denodo' connection = jaydebeapi.connect(driver, url, path) ``` Error Message: java.lang.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class com.denodo.vdp.jdbc.Driver not found I tried the following: ``` java -cp /home/I011404/Denodo_Test/driver/jdbc/denodo-vdp-jdbcdriver.jar com.denodo.vdp.jdbc.Driver Error: Main method not found in class com.denodo.vdp.jdbc.Driver, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application ``` I am using the following java version: openjdk version "1.8.0_181" OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-2~deb9u1-b13) OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode) The path to the denodo driver is correct. Am I missing something? It looks like I did not setup java correctly. Searching google and your product forum did not help. **Am I missing something?** Do I have to install the jar file somewhere, so that the class will be found? Kind Regards Moritz
user
24-01-2019 13:59:28 -0500

9 Answers

I just tried the following. ``` import psycopg2 hostname = '10.135.203.164' port = '9999' user = '#####' password = '#####' path = 'denodo_snowflake_demo' connection = psycopg2.connect( user = user, password = password, host = hostname, port = port, database = path) ``` Different error: ``` --------------------------------------------------------------------------- OperationalError Traceback (most recent call last) <ipython-input-3-99e0d55c30f6> in <module> 4 host = hostname, 5 port = port, ----> 6 database = path) /opt/conda/lib/python3.6/site-packages/psycopg2/__init__.py in connect(dsn, connection_factory, cursor_factory, **kwargs) 128 129 dsn = _ext.make_dsn(dsn, **kwargs) --> 130 conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 131 if cursor_factory is not None: 132 conn.cursor_factory = cursor_factory OperationalError: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. ```
user
25-01-2019 08:03:54 -0500
Hi, I think the only thing missing is the [user, password] argument in the connection call. Try this: connection = jaydebeapi.connect(driver, url, [user, password], path) And it should work. Alternatively, you could configure a CLASSPATH environment variable which includes the denodo jar file if you'd like to externalize it from your code. Hope this helps.
Denodo Team
25-01-2019 08:18:22 -0500
Tried the following, still does not work. ``` import jaydebeapi hostname = '#####' port = '#####' driver = 'com.denodo.vdp.jdbc.Driver' user = '#####' password = '#####' path = '/home/I011404/Denodo_Test/driver/jdbc/driver/jdbc/denodo-vdp-jdbcdriver.jar' url = 'jdbc:vdb://'+hostname+':'+port+'/denodo_snowflake_demo' connection = jaydebeapi.connect(driver, url, [user, password], path) ``` Same error: ``` --------------------------------------------------------------------------- java.lang.RuntimeExceptionPyRaisable Traceback (most recent call last) <ipython-input-4-3134a5cf89e4> in <module> ----> 1 connection = jaydebeapi.connect(driver, url, [user, password], path) /opt/conda/lib/python3.6/site-packages/jaydebeapi/__init__.py in connect(jclassname, url, driver_args, jars, libs) 379 else: 380 libs = [] --> 381 jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs) 382 return Connection(jconn, _converters) 383 /opt/conda/lib/python3.6/site-packages/jaydebeapi/__init__.py in _jdbc_connect_jpype(jclassname, url, driver_args, jars, libs) 188 return jpype.JArray(jpype.JByte, 1)(data) 189 # register driver for DriverManager --> 190 jpype.JClass(jclassname) 191 if isinstance(driver_args, dict): 192 Properties = jpype.java.util.Properties /opt/conda/lib/python3.6/site-packages/jpype/_jclass.py in JClass(name) 71 jc = _jpype.findClass(name) 72 if jc is None: ---> 73 raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name) 74 75 return _getClassFor(jc) java.lang.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class com.denodo.vdp.jdbc.Driver not found ``` Would you recommend using jaydebeapi or sqlalchemy with psycopg2? Cheers and THanks for your reply
user
25-01-2019 08:20:53 -0500
Hi, Your syntax looks correct to me. I think it's probably a matter of double-checking that the path variable is correctly entered to point to the jar file on the filesystem... Make sure that there are no copy/paste errors for example. Hope this helps!
Denodo Team
25-01-2019 08:54:13 -0500
Hey, thank you again for your answer. A colleague mentioned the same. But nope, the path is correct. ``` import jaydebeapi, os hostname = '#####' port = '#####' driver = 'com.denodo.vdp.jdbc.Driver' user = '#####' password = '#####' path = '/home/I011404/Denodo_Test/driver/jdbc/denodo-vdp-jdbcdriver-7.0-update-20181011.jar' url = 'jdbc:vdb://'+hostname+':'+port+'/denodo_snowflake_demo' ``` ``` print(os.path.isfile(path)) ``` `True` ``` connection = jaydebeapi.connect(driver, url, [user, password], path) ``` ``` java.lang.RuntimeExceptionPyRaisable Traceback (most recent call last) <ipython-input-27-3134a5cf89e4> in <module> ----> 1 connection = jaydebeapi.connect(driver, url, [user, password], path) /opt/conda/lib/python3.6/site-packages/jaydebeapi/__init__.py in connect(jclassname, url, driver_args, jars, libs) 379 else: 380 libs = [] --> 381 jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs) 382 return Connection(jconn, _converters) 383 /opt/conda/lib/python3.6/site-packages/jaydebeapi/__init__.py in _jdbc_connect_jpype(jclassname, url, driver_args, jars, libs) 188 return jpype.JArray(jpype.JByte, 1)(data) 189 # register driver for DriverManager --> 190 jpype.JClass(jclassname) 191 if isinstance(driver_args, dict): 192 Properties = jpype.java.util.Properties /opt/conda/lib/python3.6/site-packages/jpype/_jclass.py in JClass(name) 71 jc = _jpype.findClass(name) 72 if jc is None: ---> 73 raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name) 74 75 return _getClassFor(jc) java.lang.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class com.denodo.vdp.jdbc.Driver not found ```
user
25-01-2019 09:01:24 -0500
Forgot to mention: I run it in a Docker Container.
user
25-01-2019 09:02:29 -0500
Hi, I'd make sure the application has access to the path where the driver is placed. I'd also ensure the jar is the correct since by default the driver jar name is denodo-vdp-jdbcdriver.jar. I recommend to perform a test to discard an issue with the jar file or the classpath: Try to connect to Denodo from another client different than the python application using the same driver path and check if it works. Hope this helps!
Denodo Team
09-04-2019 08:29:33 -0400
It looks like you're using Windows. I made all the same moves you did and got all the same results. What ended up working for me was to change from backslashes to forwards ("\" to "/") and despite that looking wrong for Windows it seems that Python or Java does the translation internally. That worked for me. I was able to connect.
user
 Edited on: 05-08-2019 14:40:37 -0400
This worked for me: Make sure to start the JVM via jpype and specify the path of the driver jar before openning the connection. jpype.startJVM(jvmPath, "-Djava.class.path="+ABSOLUTE_PATH_JDBC_DENODO_DRIVER, )
user
13-01-2020 03:33:12 -0500
You must sign in to add an answer. If you do not have an account, you can register here