【发布时间】:2016-01-20 17:18:38
【问题描述】:
我正在尝试使用我创建的 Python 脚本从数据库中提取一些表...
import jaydebeapi as jdbc
import pandas.io.sql as psql
import pandas
import getpass
import yaml
p = yaml.load(file("/Users/glassjawed/.TD"))
# Contains password
c = jdbc.connect('com.teradata.jdbc.TeraDriver'
,['jdbc:teradata://******.***.***.com','glassjawed',p]
,['~/terajdbc4.jar','~/tdgssconfig.jar'])
# read in the table we want
df = psql.read_sql('SELECT TOP 10 user_id FROM store_users',c)
print(pandas.DataFrame.head(df))
print(type(df))
但我遇到了以下错误。
File "EPNconnect.py", line 11, in <module>
,['~/terajdbc4.jar','~/tdgssconfig.jar'])
File "/usr/lib/python2.7/dist-packages/jaydebeapi/__init__.py", line 359, in connect
jconn = _jdbc_connect(jclassname, jars, libs, *driver_args)
File "/usr/lib/python2.7/dist-packages/jaydebeapi/__init__.py", line 182, in _jdbc_connect_jpype
jpype.JClass(jclassname)
File "/usr/lib/python2.7/dist-packages/JPype1-0.6.1-py2.7-linux-x86_64.egg/jpype/_jclass.py", 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
我安装了最新的 jar 文件,但仍然出现此错误。我不知道如何解决这个问题。帮忙?
【问题讨论】:
-
我出演了 ******.***.***.com 因为我不想透露我的工作地点。
-
你确定你有 terajdbc4.jar 和 tdgssconfig.jar 吗?我看到您在
.connect调用中列出了它们,但错误表明其中一个可能不存在于您用户的主目录中。此外,由于您使用的是~主目录别名,因此请确保您以在其主目录中具有两个 jar 文件的用户身份运行此脚本。 -
请看我的回答@Glassjawed。确保您已包含所有依赖项。