1

I'm trying to connect to a Postgres DB using a the redshift-fake-driver (https://github.com/opt-tech/redshift-fake-driver) within my python code. However I can't get the driver to load.

I'm running the python code within a docker container based on the rappdw/docker-java-python image

import jpype
import os
import inspect
import jaydebeapi

jar = r'/drivers/redshift-fake-driver_2.12-1.0.10.jar'
args='-Djava.class.path=%s' % jar
jvm_path = jpype.getDefaultJVMPath()
jpype.startJVM(jvm_path, '-ea', args)

conn = jaydebeapi.connect('jp.ne.opt.redshiftfake.postgres.FakePostgresqlDriver',"localhost", "airflow","airflow")
curs = conn.cursor()

Current i'm getting this exception:

 File "/test.py", line 12, in <module>
    "loclahost", "airflow","airflow")
  File "/usr/local/lib/python3.6/site-packages/jaydebeapi/__init__.py", line 381, in connect
    jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
  File "/usr/local/lib/python3.6/site-packages/jaydebeapi/__init__.py", line 190, in _jdbc_connect_jpype
    jpype.JClass(jclassname)
  File "/usr/local/lib/python3.6/site-packages/jpype/_jclass.py", line 73, in JClass
    raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name)
jpype._jexception.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class jp.ne.opt.redshiftfake.postgres.FakePostgresqlDriver not found
  • Could the error be on the following line: `conn = jaydebeapi.connect('jp.ne.opt.redshiftfake.postgres.FakePostgresqlDriver',"loclahost", "airflow","airflow")` Where instead of loclahost it would be localhost? – landocalrissian Feb 10 '19 at 05:15
  • Corrected that typeo, and still get the same error. I'm lost on why it can't find / load the class from the jar file. I've confirmed it's there with "tar -tf redshift-fake-driver_2.12-1.0.10.jar" – Denis Abalakov Feb 11 '19 at 16:00
  • I took a look at how jaydebeapi connects to a database. Following the example would the following work: `jaydebeapi.connect("jp.ne.opt.redshiftfake.postgres.FakePostgresqlDriver","jdbc:postgresqlredshift://localhost:/",["SA", ""],"") ` Where the db port, db name, and path to redshift jar would need to be filled in. – landocalrissian Feb 11 '19 at 23:57

0 Answers0