java.lang.RuntimeExceptionPyRaisable: java.lang.Ru

2020-02-02 03:20发布

问题:

I am trying to connect with Teradata database in Mac 10.14.2 using Jaydebeapi. I am getting following error. Earlier, I was facing issue in installing Jaydebeapi. After lot of trials and errors. I downgraded Python 3.7 to Python 3.6. Following are the code and corresponding error output

Code

import sys
import os
import string
import jaydebeapi
from time import gmtime, strftime
from datetime import datetime, timedelta
case_detail_server ='*******'
amanita_server= '******'

database_case_detail='CASE_DETAILS_APP'
user_case_detail='****'
password_case_detail='!****'
jars= ['/Users/AppleUser/anaconda3/envs/py36/lib/tdgssconfig.jar','/Users/AppleUser/anaconda3/envs/py36/lib/terajdbc4.jar']
jclassname_case_detail='com.teradata.jdbc.TeraDriver'
case_detail_url='jdbc:teradata://xyz/DBS_PORT=1025,TMODE=ANSI,CHARSET=UTF8'

conn_case_detail=jaydebeapi.connect('com.teradata.jdbc.TeraDriver',case_detail_url,{'user': user_case_detail, 'password': password_case_detail},jars)
curs_case_detail = conn_case_detail.cursor()

curs_case_detail.execute("SELECT TOP 100 Case_Id, Case_Type_Desc FROM aca.fact_case_detail ")

Error

java.lang.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class com.teradata.jdbc.TeraDriver not found
---------------------------------------------------------------------------
java.lang.RuntimeExceptionPyRaisable      Traceback (most recent call last)
<ipython-input-59-70953f1fe337> in <module>
      6 case_detail_url='jdbc:teradata:xyz/DBS_PORT=1025,TMODE=ANSI,CHARSET=UTF8'
      7 
----> 8 conn_case_detail=jaydebeapi.connect('com.teradata.jdbc.TeraDriver',case_detail_url,{'user': user_case_detail, 'password': password_case_detail},jars)
      9 curs_case_detail = conn_case_detail.cursor()
     10 
/anaconda3/lib/python3.6/site-packages/jaydebeapi/__init__.py in connect(jclassname, url, driver_args, jars, libs)
    379     else:
    380         libs = []
--> 381     jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
    382     return Connection(jconn, _converters)
    383 
/anaconda3/lib/python3.6/site-packages/jaydebeapi/__init__.py in _jdbc_connect_jpype(jclassname, url, driver_args, jars, libs)
    188             return jpype.JArray(jpype.JByte, 1)(data)
    189     # register driver for DriverManager
--> 190     jpype.JClass(jclassname)
    191     if isinstance(driver_args, dict):
    192         Properties = jpype.java.util.Properties
/anaconda3/lib/python3.6/site-packages/jpype/_jclass.py in JClass(name)
     71     jc = _jpype.findClass(name)
     72     if jc is None:
---> 73         raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name)
     74 
     75     return _getClassFor(jc)
java.lang.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class com.teradata.jdbc.TeraDriver not found

Please help. Thanks in advance! Mi

回答1:

I rechecked all the database names and url. Found everything was correct. Then, I re-downloaded Teradata JDBC drivers from here:

https://downloads.teradata.com/download/connectivity/jdbc-driver

jars=['/CorrectPath/tdgssconfig.jar','/CorrectPAth/terajdbc4.jar']

Unpacked and gave the new path. And found it's working.

Strange! But, I got the solution. :)