Problem connecting to teradata using Python jaydebeapi module


Problem connecting to teradata using Python jaydebeapi module

Hi guys,


I've tried everything (e.g. troubleshooting, googling, etc) and am unable to solve this and am hoping that some of you can help me.


I'm trying to connect to a teradata server using the JDBC drivers provided. While I can do this within R, for some reason I keep running into errors with Python. My code is:


import jpype

import jaydebeapi

classpath = "~/tdgssconfig.jar;~/terajdbc4.jar"

jvm_path = "/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/jre/lib/server/libjvm.dylib"

jpype.startJVM(jvm_path, "-Djava.class.path=%s" % classpath)

conn = jaydebeapi.connect('com.teradata.jdbc.TeraDriver', 'jdbc:teradata://TERADATA.SERVER.ADDRESS' , USERNAME', 'PASSWORD', ["~/tdgssconfig.jar","~/terajdbc4.jar"])

Each time I run the above code, I'll get to the last line and the following error appears:


Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/jaydebeapi/", line 359, in connect

    jconn = _jdbc_connect(jclassname, jars, libs, *driver_args)

  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/jaydebeapi/", line 182, in _jdbc_connect_jpype


  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/jpype/", line 55, in JClass

    raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name)

jpype._jexception.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class com.teradata.jdbc.TeraDriver not found


I'm inferring from the error that the module is having trouble finding the drivers.  But I've confirmed multiple times that I can access the drivers at the location I've listed AND have tried moving the drivers to different locations, specifying the full path, etc. I don't know what's going on and why the module won't find it. Anybody have any ideas? I'm running Python 3.5 on Mac OSX 10.11.2. As indicated from the code, I'm using Java 1.8.



Re: Problem connecting to teradata using Python jaydebeapi module

I figured out the problem. With Macs, you can't use ";" as a separator and need to change it to ":". Changing the line

classpath = "~/tdgssconfig.jar:~/terajdbc4.jar"

did the trick. For anyone else interested, I also used 

JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"

in the terminal so that I wouldn't have to worry about it in the python console.