python+jaydebeapi同时连接两个不同数据库,提示找不到com.mysql.jdbc.Driver

如果同时连接两个不同类型的数据库,会报找不到java类例如 :提示找不到com.mysql.jdbc.Driver

 

以下是我的解决办法

driver = ‘oracle.jdbc.OracleDriver‘
url = ‘jdbc:oracle:thin:@ip:1521/orcl11g.us.oracle.com‘

user = ‘****‘

password = ‘****‘
jarFile = [‘./driver_file/ojdbc8.jar‘, ‘./driver_file/oceanbase-client-1.1.0.jar‘, ‘./driver_file/db2jcc4.jar‘, ‘./driver_file/mysql-connector-java-5.1.39-bin.jar‘]
conn = jaydebeapi.connect(jclassname=driver, url=url, driver_args=[user, password], jars=jarFile)

 

driver1 = com.mysql.jdbc.Driver‘
url1 = ‘jdbc:mysql://ip:3306/sqltest‘

user1 = ‘****‘

password1 = ‘****‘
conn1 = jaydebeapi.connect(jclassname=driver1, url=url1, driver_args=[user1, password1], jars=jarFile)

 

因为jpype只能调用一次,最新版本jaydebeapi允许传一个list包含所有jar包路径

python+jaydebeapi同时连接两个不同数据库,提示找不到com.mysql.jdbc.Driver

上一篇:sql 获取连续年份


下一篇:Greenplum6 数据库数据库学习_基本语法