如何使用JayDeBeApi模块以及Python3中的SAP Sybase JDBC驱动程序(jconn4.jar)连接到Netcool / Omnibus“对象服务器”?

时间:2017-05-31 14:28:05

标签: jdbc python-3.5

我是python编程的新手。我尝试使用Python3连接到Netcool对象服务器,我使用JayDeBeApi模块和SAP Sybase JDBC驱动程序(jconn4.jar)

以下是示例脚本:

import jaydebeapi
server="xxx"
database="xx"
user="xx"
password="xx"

jclassname='com.sybase.jdbc4.jdbc.SybDriver'
url='jdbc:sybase:Tds://'+server+'/'+database
driver_args=[url,user,password]
jars="path/jconn4.jar"

conn=jaydebeapi.connect(jclassname,driver_args,jars)
curs = conn.cursor()
curs.execute("select * from status")
curs.fetchall()`

当我执行脚本时,它显示如下错误

File "sample.py", line 12, in <module>
    conn=jaydebeapi.connect(jclassname,driver_args,jars)
  File "/usr/local/lib/python3.5/site-packages/jaydebeapi/__init__.py", line 381, in connect
    jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
  File "/usr/local/lib/python3.5/site-packages/jaydebeapi/__init__.py", line 199, in _jdbc_connect_jpype
    return jpype.java.sql.DriverManager.getConnection(url, *dargs)
RuntimeError: No matching overloads found. at native/common/jp_method.cpp:117

如果有人在Python3中使用JayDeBeApi模块成功连接到Netcool对象服务器?请分享示例脚本

感谢

1 个答案:

答案 0 :(得分:0)

您指定的网址格式不正确。以下内容适用于我。

url = jdbc:sybase:Tds:++hostname:++dbport/++dbname

e.g

conn = jaydebeapi.connect('com.sybase.jdbc4.jdbc.SybDriver', ['jdbc:sybase:Tds:hostA:8888/db1','root',''],['path/jconn4.jar'])