找不到Python jaydebeapi类com.sybase.jdbc4.jdbc.SybDriver

时间:2019-05-27 04:56:44

标签: python-2.7 sybase tivoli jpype jaydebeapi

我正在尝试使用Jconn4和jaydebeapi软件包连接到IBM OMNIBUS对象服务器数据库,但是我一直在获得

jpype._jexception.RuntimeExceptionPyRaisable:java.lang.RuntimeException:找不到com.sybase.jdbc4.jdbc.SybDriver类

我尝试将jconn4.jar移至Java的安装位置并更改代码中的路径

import jaydebeapi
import os
import jpype                                                                                                                                                                                                                     
conn = jaydebeapi.connect('com.sybase.jdbc4.jdbc.SybDriver', ['jdbc:sybase:Tds:ip:4100/alerts','user','pass'],['/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/lib/jconn4.jar'])
curs = conn.cursor()

我的输出看起来像

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    conn = jaydebeapi.connect('com.sybase.jdbc4.jdbc.SybDriver', ['jdbc:sybase:Tds:ip:4100/alerts','user','pass'],['/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/lib/jconn4.jar'])
  File "/usr/lib/python2.7/site-packages/jaydebeapi/__init__.py", line 381, in connect
    jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
  File "/usr/lib/python2.7/site-packages/jaydebeapi/__init__.py", line 190, in _jdbc_connect_jpype
    jpype.JClass(jclassname)
  File "/usr/lib64/python2.7/site-packages/jpype/_jclass.py", line 73, in JClass
    raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name)
jpype._jexception.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class com.sybase.jdbc4.jdbc.SybDriver not found

1 个答案:

答案 0 :(得分:0)

我相信connect函数的参数是:类名,URL,args,jar路径。

您可以尝试:

conn = jaydebeapi.connect('com.sybase.jdbc4.jdbc.SybDriver', 'jdbc:sybase:Tds:ip:4100/alerts', {'user': 'user', 'password': 'pass'}, '/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/lib/jconn4.jar')