将Python与JDBC连接时出现错误

时间:2019-12-03 13:27:14

标签: python jvm database-connectivity jaydebeapi

当我尝试将Python与JDBC连接时。我遇到错误

con = jaydebeapi.connect(driver_class,connection_string,[uid,pwd],driver_file)     追溯(最近一次通话):

  File "<ipython-input-59-e129793394dc>", line 1, in <module>
    con = jaydebeapi.connect(driver_class, connection_string, [uid, pwd], driver_file)

  File "C:\Users\kroy\AppData\Local\Continuum\anaconda3\lib\site-packages\jaydebeapi\__init__.py", line 381, in connect
    jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)

  File "C:\Users\kroy\AppData\Local\Continuum\anaconda3\lib\site-packages\jaydebeapi\__init__.py", line 176, in _jdbc_connect_jpype
    jpype.startJVM(jvm_path, *args)

  File "C:\Users\kroy\AppData\Local\Continuum\anaconda3\lib\site-packages\jpype\_core.py", line 157, in startJVM
    raise OSError('JVM cannot be restarted')

**OSError: JVM cannot be restarted**```

这是我要连接的代码

import jpype
import pyodbc 

#export PYMSSQL_BUILD_WITH_BUNDLED_FRE

# Data Virtuality Server Details
driver_class='org.teiid.jdbc.TeiidDriver'
host = "jdv.prod.a4.vary.*******.com"
port = "31000"
database = "SALES_VDM"
use_ssl = True
uid = "*******"
pwd = "************"
jar_file="C:\Program Files\DBeaver\teiid-10.3.5-jdbc.jar"

if (use_ssl):
 connection_string="jdbc:teiid:sales_vdm@mms://jdv.prod.a4.vary.********.com:31001".format(database, host, port)
else:
 connection_string="jdbc:teiid:sales_vdm@mms://jdv.prod.a4.vary.*********.com:31000".format(database, host, port)

con = jaydebeapi.connect(driver_class, connection_string, [uid, pwd], jar_file)


0 个答案:

没有答案