java.lang.RuntimeExceptionPyRaisable:java.lang.RuntimeException:找不到类com.teradata.jdbc.TeraDriver

时间:2019-01-16 08:15:43

标签: python python-3.x teradata jaydebeapi

我正在尝试使用 Jaydebeapi 连接Mac 10.14.2中的 Teradata 数据库。我收到以下错误。之前,我在安装 Jaydebeapi 时遇到问题。经过大量的试验和错误。我将Python 3.7降级为Python 3.6。以下是代码和相应的错误输出

代码

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 ")

错误

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

请帮助。 提前致谢! Mi

1 个答案:

答案 0 :(得分:0)

我重新检查了所有数据库名称和URL。发现一切正确。然后,我从这里重新下载了Teradata JDBC驱动程序:

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

awk '!($1 in min) { k[++i] = $1; min[$1] = $2}
    $2<min[$1] { min[$1] = $2 }
END { for (j=1; j<=i; ++j) print k[j],min[k[j]] }' aaa.txt

解压并给出新路径。并发现它正在工作。

奇怪!但是,我找到了解决方案。 :)