我尝试从Raspberry pi用python发出Oracle请求。问题是:
“ Oracle不支持Raspberry Pi使用的ARM CPU架构。您下载并解压缩了Oracle Instant Client,但实际上无法运行。而且如果没有Oracle Client库,cx_oracle将无法工作,也将无法运行通用的Python ODBC连接器。”
但是我需要python,所以安装了JPype和JayDeBeApi,我在jupyter notebopok上写了这个:
import jaydebeapi
import jpype
from jpype import *
classpath="ava-1.5.0-gcj-6-armhf"
jvm_path = "/usr/lib/jvm/java-1.5.0-gcj-6-armhf/lib"
jHome = jpype.getDefaultJVMPath()
print(jHome)
/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/lib/arm/client/libjvm.so
conn=jaydebeapi.connect('oracle.jdbc.driver.OracleDriver','[admin]/[root]@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=helloworld.com)(PORT=1521))(CONNECT_DATA=(SID=hello42)))')
但是我有这个错误:
AttributeError Traceback (most recent call last)
<ipython-input-34-82d7959b353e> in <module>
----> 1 conn=jaydebeapi.connect('oracle.jdbc.driver.OracleDriver','[admin]/[root]@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=helloworld.com)(PORT=1521))(CONNECT_DATA=(SID=hello42)))')
/usr/local/lib/python3.5/dist-packages/jaydebeapi/__init__.py in connect(jclassname, url, driver_args, jars, libs)
379 else:
380 libs = []
--> 381 jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
382 return Connection(jconn, _converters)
383
/usr/local/lib/python3.5/dist-packages/jaydebeapi/__init__.py in _jdbc_connect_jpype(jclassname, url, driver_args, jars, libs)
181 types_map = {}
182 for i in types.__javaclass__.getClassFields():
--> 183 types_map[i.getName()] = i.getStaticAttribute()
184 _init_types(types_map)
185 global _java_array_byte
AttributeError: '_jpype.PyJPField' object has no attribute 'getStaticAttribute'
该如何解决?
答案 0 :(得分:3)
您使用什么JPype版本?上周发布了一个新版本。如果您使用的是0.7.0版,请尝试使用以前的0.6.3版