pythonjaydebeapi

Python 3 - jaydebeapi - Connect to an Oracle Database


I recently downloaded the jaydebeapi library and I am struggling to connect to a remote Oracle database. I am doing the following:

import jaydebeapi as j
j.connect('oracle.jdbc.driver.OracleDriver', ['jdbc:oracle:thin:@myhost:port:instance_name', "user", "pass"], "/path/to/ojdbc7.jar")

In this case I receive the error:

FileNotFoundError: [WinError 2] The system cannot find the file specified

although the jar file is located in the indicated folder.

If I omit the path to ojdbc7.jar I receive:

import jaydebeapi as j
    j.connect('oracle.jdbc.driver.OracleDriver', ['jdbc:oracle:thin:@myhost:port:instance_name', "user", "pass"])

TypeError                                 Traceback (most recent call last)
<ipython-input-164-db519a221754> in <module>()
----> 1 j.connect('oracle.jdbc.driver.OracleDriver', 'jdbc:oracle:thin:@cdwprdmi-scan.int-app.stockex.com:1522:mdwprdmi1',)

L:\pyzo2015a\lib\site-packages\jaydebeapi\__init__.py in connect(jclassname, driver_args, jars, libs)
     61 
     62         gateway = java_gateway.JavaGateway.launch_gateway(
---> 63             port=25333, classpath=classpath, javaopts=javaopts, die_on_exit=True)
     64 
     65         java_gateway.java_import(gateway.jvm, 'java.sql.DriverManager')

L:\pyzo2015a\lib\site-packages\py4j\java_gateway.py in launch_gateway(cls, port, jarpath, classpath, javaopts, die_on_exit, redirect_stdout, redirect_stderr, daemonize_redirect, java_path, create_new_process_group)
   1977             daemonize_redirect=daemonize_redirect, java_path=java_path,
   1978             create_new_process_group=create_new_process_group)
-> 1979         gateway = JavaGateway(gateway_parameters=GatewayParameters(port=_port))
   1980         return gateway
   1981 

L:\pyzo2015a\lib\site-packages\py4j\java_gateway.py in launch_gateway(port, jarpath, classpath, javaopts, die_on_exit, redirect_stdout, redirect_stderr, daemonize_redirect, java_path, create_new_process_group)
    282     # Launch the server in a subprocess.
    283     classpath = os.pathsep.join((jarpath, classpath))
--> 284     command = [java_path, "-classpath", classpath] + javaopts +     285               ["py4j.GatewayServer"]
    286     if die_on_exit:

TypeError: sequence item 1: expected str instance, NoneType found

How can I solve the problem here? Thanks,


Solution

  • The issue was due to the fact that jaydebeapi use the command java to execute a java jar. Unfortunately the computer I work with only accept the absolute path of java so I needed to reference it while calling the connect method jaydebeapi. Thanks,