-1

I am trying to connect to my GaussDB or even PostgreSQL using in python JayDeBeApi from linux, but I keep getting this error:

Error Class com.gauss.driver not found

I copy my jar file to /usr/lib/jvm/java-11-openjdk-amd46/lib/com.driver.jar

is there something else ?

import jaydebeapi
import sys
 jaydebeapi.connect("com.gauss.Driver",
    url, [username, password], "./file-jdbc.jar")
henrycarteruk
  • 12,708
  • 2
  • 36
  • 40
Niklas
  • 1
  • 2
  • Please provide enough code so others can better understand or reproduce the problem. – Community Sep 10 '22 at 04:20
  • Copying random drivers into a Java installation will not automagically add them to the class path, and it is not something you should do. Why do you think that would work? – Mark Rotteveel Sep 12 '22 at 07:33
  • So what should I do please? I am not familiar with class path in linux – Niklas Sep 14 '22 at 21:08

1 Answers1

0

You can try to explicitly start a JVM and pass it the fullpath of your driver jar file:


import jaydebeapi
import jpype

jpype.startJVM(jpype.getDefaultJVMPath(),
                   f"-Djava.class.path=/usr/lib/jvm/java-11-openjdk-amd46/lib/com.driver.jar")


jaydebeapi.connect("com.gauss.Driver", url, [username, password], "/usr/lib/jvm/java-11-openjdk-amd46/lib/")

If you're using postgresSQL databases I would also suggest you to take a look to the psycopg library:

https://pypi.org/project/psycopg/

https://www.geeksforgeeks.org/introduction-to-psycopg2-module-in-python/