You can translate the question and the replies:

How to connect using JDBC driver in Python?

###Connection using JDBC import jaydebeapi hostname = 'server name' port = '####' driver = 'com.denodo.vdp.jdbc.Driver' user = '####' password = '#####' path = '/C:/Users/abc/Desktop/Projects/denodo-vdp-jdbcdriver.jar' url = 'jdbc:vdb://'+hostname+':'+port+'/denodo' connection = jaydebeapi.connect(driver, url, path) It's not working. What am I making mistake?
user
15-02-2022 18:36:49 -0500
code

6 Answers

Hi, To connect to the Denodo Platform from Python using the JDBC drivers, you can utilize the Python library like jaydebeapi. The relevant parameters such as JDBC driver, username, password can be put into the function connect() to make the connection work. In order to establish the connection successfully, you could refer to the [How to connect to Denodo from Python - a starter for Data Scientists](https://community.denodo.com/kb/en/view/document/How%20to%20connect%20to%20Denodo%20from%20Python%20-%20a%20starter%20for%20Data%20Scientists?category=Northbound%20Connections) Knowledge Base article for additional information on the connection. Suppose if you still need help and if you are a valid support user then you could raise a support case on Denodo [Support Site](https://support.denodo.com/MainPage.do) so that our support team can help you. Hope this helps!
Denodo Team
16-02-2022 07:56:06 -0500
code
I am not able to get the working connection. What am I doing wrong? Here is the code- ###Connection using JDBC import jaydebeapi hostname = 'denodo.us.pre.corp' port = '9996' driver = 'com.denodo.vdp.jdbc.Driver' user = 'sc_n750248' password = '#####' path = '/C:/Users/gjindal/Desktop/Projects/Flamingo/denodo-vdp-jdbcdriver/denodo-vdp-jdbcdriver.jar' url = 'jdbc:vdb://'+hostname+':'+port+'/denodo' connection = jaydebeapi.connect(driver, url, path)
user
 Edited on: 16-02-2022 10:10:02 -0500
Hi, Going through the syntax, I believe you haven't added the two arguments [user, password] in the connection call. You could add the argument in the connection call by following the syntax: ``` connection = jaydebeapi.connect(driver, url, [user, password], path) ``` For more information, you could refer to the similar - [Q&A](https://community.denodo.com/answers/question/details?questionId=9060g000000fzrIAAQ&title=Connection+from+Python+to+Denodo) and [How to connect to Denodo from Python - a starter for Data Scientists](https://community.denodo.com/kb/en/view/document/How%20to%20connect%20to%20Denodo%20from%20Python%20-%20a%20starter%20for%20Data%20Scientists?category=Northbound%20Connections) Knowledge Base article which provides sample code to connect to the Denodo server using the jaydebeapi library. Hope this helps!
Denodo Team
17-02-2022 07:07:58 -0500
code
import jaydebeapi as dbdriver from socket import gethostname denodoserver_name = "denodo.us.pre.corp" denodoserver_jdbc_port = "9999" denodoserver_database = "irmorm_vdb" denodoserver_uid = "###" denodoserver_pwd = "###" denododriver_path = "C:/Users/gjindal/Desktop/Projects/Flamingo/denodo-vdp-jdbcdriver/denodo-vdp-jdbcdriver.jar" client_hostname = gethostname() useragent = "%s-%s" % (dbdriver.__name__,client_hostname) conn_uri = "jdbc:vdb://%s:%s/%s?userAgent=%s" % (denodoserver_name, denodoserver_jdbc_port, denodoserver_database, useragent) cnxn = dbdriver.connect( "com.denodo.vdp.jdbc.Driver", conn_uri, driver_args = {"user": denodoserver_uid, "password": denodoserver_pwd}, jars = denododriver_path ) query = "select * from irmorm_vdb" cur = cnxn.cursor() cur.execute(query) results = cur.fetchall()
user
04-03-2022 12:49:46 -0500
Exception: Java Exception The above exception was the direct cause of the following exception: java.sql.SQLException Traceback (most recent call last) ~\AppData\Local\Temp\1/ipykernel_33172/2795276467.py in <module> 13 14 conn_uri = "jdbc:vdb://%s:%s/%s?userAgent=%s" % (denodoserver_name, denodoserver_jdbc_port, denodoserver_database, useragent) ---> 15 cnxn = dbdriver.connect( "com.denodo.vdp.jdbc.Driver", 16 conn_uri, 17 driver_args = {"user": denodoserver_uid, ~\Anaconda3\lib\site-packages\jaydebeapi\__init__.py in connect(jclassname, url, driver_args, jars, libs) 410 else: 411 libs = [] --> 412 jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs) 413 return Connection(jconn, _converters) 414 ~\Anaconda3\lib\site-packages\jaydebeapi\__init__.py in _jdbc_connect_jpype(jclassname, url, driver_args, jars, libs) 228 else: 229 dargs = driver_args --> 230 return jpype.java.sql.DriverManager.getConnection(url, *dargs) 231 232 def _get_classpath(): java.sql.SQLException: java.sql.SQLException: connection error: Connection timed out: connect
user
04-03-2022 13:04:21 -0500
Hi, I understand that when your are trying to connect to the Denodo Platform from Python using the JDBC drivers, you are receiving the exception as ‘java.sql.SQLException: java.sql.SQLException: connection error: Connection timed out: connect’. I believe that the above error could be due to some network issue such as firewalls or ports blocked that prevent the connections. Hence, to resolve the issue I would perform the following checks: * I would check if the required ports are allowed through the firewall and network configuration. * I would also confirm if the RMI hostname of the server has been configured accordingly. * If still the connection fails, I would check the vdp.log file located under the directory <DENODO_HOME>/logs/vdp. Suppose if you still need help and if you are a valid support user then you can raise a support case on Denodo [Support Site](https://support.denodo.com/MainPage.do) so that our support team can help you. Hope this helps!
Denodo Team
08-03-2022 06:08:14 -0500
code
You must sign in to add an answer. If you do not have an account, you can register here