From 12d8ee4d4a4219887a90435ec59743d4b037f999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D0=B5=D0=BC=20=D0=A1=D1=82=D0=B0=D1=80?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=BA=D0=BE?= <41ways1ucky@gmail.com> Date: Tue, 25 Jun 2019 16:45:45 +0300 Subject: [PATCH 1/2] Fixed incompatibility with JPype1 v0.7.0 * replaced call to deleted method getStaticAttribute with call to __get__ * added parameter convertStrings=True to mimic old default behaviour of JPype1 see [docs](https://jpype.readthedocs.io/en/latest/api.html#jpype.startJVM) --- jaydebeapi/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jaydebeapi/__init__.py b/jaydebeapi/__init__.py index ecb5ef1..f89d301 100644 --- a/jaydebeapi/__init__.py +++ b/jaydebeapi/__init__.py @@ -192,7 +192,7 @@ def _jdbc_connect_jpype(jclassname, url, driver_args, jars, libs): types = jpype.java.sql.Types types_map = {} for i in types.__javaclass__.getClassFields(): - types_map[i.getName()] = i.getStaticAttribute() + types_map[i.getName()] = i.__get__(i) _init_types(types_map) global _java_array_byte if _java_array_byte is None: From 002f3c7e9a233b8bb55b73087de1dabfc1b545cd Mon Sep 17 00:00:00 2001 From: baztian Date: Mon, 8 Jul 2019 22:33:36 +0200 Subject: [PATCH 2/2] Reintroduce compatibility for post 0.7 JPype versions --- jaydebeapi/__init__.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/jaydebeapi/__init__.py b/jaydebeapi/__init__.py index f89d301..ab75c49 100644 --- a/jaydebeapi/__init__.py +++ b/jaydebeapi/__init__.py @@ -74,6 +74,8 @@ _java_array_byte = None _handle_sql_exception = None +old_jpype = False + def _handle_sql_exception_jython(): from java.sql import SQLException exc_info = sys.exc_info() @@ -173,15 +175,17 @@ def _jdbc_connect_jpype(jclassname, url, driver_args, jars, libs): # jvm_path = ('/usr/lib/jvm/java-6-openjdk' # '/jre/lib/i386/client/libjvm.so') jvm_path = jpype.getDefaultJVMPath() - jpype_ver = 0. + global old_jpype if hasattr(jpype, '__version__'): try: ver_match = re.match('\d+\.\d+', jpype.__version__) if ver_match: jpype_ver = float(ver_match.group(0)) + if jpype_ver < 0.7: + old_jpype = True except ValueError: pass - if jpype_ver < 0.7: + if old_jpype: jpype.startJVM(jvm_path, *args) else: jpype.startJVM(jvm_path, *args, ignoreUnrecognized=True, @@ -192,7 +196,11 @@ def _jdbc_connect_jpype(jclassname, url, driver_args, jars, libs): types = jpype.java.sql.Types types_map = {} for i in types.__javaclass__.getClassFields(): - types_map[i.getName()] = i.__get__(i) + if old_jpype: + const = i.getStaticAttribute() + else: + const = i.__get__(i) + types_map[i.getName()] = const _init_types(types_map) global _java_array_byte if _java_array_byte is None: