From 296790bb98f8c08f2516821b3560c6f61f7413df Mon Sep 17 00:00:00 2001 From: Amin Ghadersohi Date: Sat, 26 Sep 2026 07:14:33 +0000 Subject: [PATCH] Remove the zxJDBC dialect and its entry points ibm_db_sa/zxjdbc.py imports sqlalchemy.connectors.zxJDBC, which SQLAlchemy removed in 1.4, and the dialect itself only runs on Jython, which cannot install this package (python_requires >= 3.9). The four sqlalchemy.dialects entry points that point at it therefore always fail to load with ModuleNotFoundError. Applications that enumerate installed dialects through entry points (for example to list available databases) hit and log that error on every scan. Drop the module, its four entry points and the matching test registrations. The ibm_db, pyodbc and AS/400 dialects are unchanged. --- README.md | 2 +- ibm_db_sa/zxjdbc.py | 95 --------------------------------------------- run_tests.py | 2 - setup.py | 4 -- 4 files changed, 1 insertion(+), 102 deletions(-) delete mode 100644 ibm_db_sa/zxjdbc.py diff --git a/README.md b/README.md index b4bd167..b953229 100644 --- a/README.md +++ b/README.md @@ -219,7 +219,7 @@ Known Limitations in ibm_db_sa adapter for DB2 databases 4) UPDATE CASCADE for foreign keys not supported 5) DEFERRABLE INITIALLY deferred not supported 6) Subquery in ON clause of LEFT OUTER JOIN not supported -7) PyODBC and Jython/zxjdbc support is experimental +7) PyODBC support is experimental Credits diff --git a/ibm_db_sa/zxjdbc.py b/ibm_db_sa/zxjdbc.py deleted file mode 100644 index 6ef5b20..0000000 --- a/ibm_db_sa/zxjdbc.py +++ /dev/null @@ -1,95 +0,0 @@ -# +--------------------------------------------------------------------------+ -# | Licensed Materials - Property of IBM | -# | | -# | (C) Copyright IBM Corporation 2008, 2016. | -# +--------------------------------------------------------------------------+ -# | This module complies with SQLAlchemy 0.8 and is | -# | Licensed under the Apache License, Version 2.0 (the "License"); | -# | you may not use this file except in compliance with the License. | -# | You may obtain a copy of the License at | -# | http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable | -# | law or agreed to in writing, software distributed under the License is | -# | distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | -# | KIND, either express or implied. See the License for the specific | -# | language governing permissions and limitations under the License. | -# +--------------------------------------------------------------------------+ -# | Author: Jaimy Azle | -# | Contributor: Mike Bayer | -# +--------------------------------------------------------------------------+ - -# raise NotImplementedError( -# "The zxjdbc dialect is not implemented at this time.") - - -# NOTE: it appears that to use zxjdbc, the "RETURNING" syntax -# must be installed in DB2, which appears to be optional. It would -# be best if the RETURNING support were built into the base dialect -# and not be local to zxjdbc here. - -from decimal import Decimal as _python_Decimal -from sqlalchemy import sql, util -from sqlalchemy import types as sa_types -from sqlalchemy.connectors.zxJDBC import ZxJDBCConnector -from .base import _SelectLastRowIDMixin, DB2Dialect, DB2ExecutionContext, DB2Compiler -from . import reflection as ibm_reflection - -class DB2ExecutionContext_zxjdbc(DB2ExecutionContext): - - def create_cursor(self): - cursor = self._dbapi_connection.cursor() - cursor.datahandler = self.dialect.DataHandler(cursor.datahandler) - return cursor - -class DB2Dialect_zxjdbc(ZxJDBCConnector, DB2Dialect): - - supports_unicode_statements = supports_unicode_binds = \ - returns_unicode_strings = supports_unicode = False - supports_sane_multi_rowcount = False - - supports_unicode_statements = False - supports_sane_rowcount = True - supports_char_length = True - - jdbc_db_name = 'db2' - jdbc_driver_name = 'com.ibm.db2.jcc.DB2Driver' - - statement_compiler = DB2Compiler - execution_ctx_cls = DB2ExecutionContext_zxjdbc - - @classmethod - def dbapi(cls): - - global SQLException, zxJDBC - from java.sql import SQLException, Types as java_Types - from com.ziclix.python.sql import zxJDBC - from com.ziclix.python.sql import FilterDataHandler - - # TODO: this should be somewhere else - class IBM_DB2DataHandler(FilterDataHandler): - - def setJDBCObject(self, statement, index, object, dbtype=None): - if dbtype is None: - if (isinstance(object, int)): - statement.setObject(index, str(object), java_Types.INTEGER) - elif (isinstance(object, long)): - statement.setObject(index, str(object), java_Types.BIGINT) - elif (isinstance(object, _python_Decimal)): - statement.setObject(index, str(object), java_Types.DECIMAL) - else: - statement.setObject(index, object) - else: - FilterDataHandler.setJDBCObject(self, statement, index, object, dbtype) - - cls.DataHandler = IBM_DB2DataHandler - return zxJDBC - - -class AS400Dialect_zxjdbc(DB2Dialect_zxjdbc): - jdbc_db_name = 'as400' - jdbc_driver_name = 'com.ibm.as400.access.AS400JDBCDriver' - - _reflector_cls = ibm_reflection.AS400Reflector - - - - diff --git a/run_tests.py b/run_tests.py index c3f9646..7e3cba7 100644 --- a/run_tests.py +++ b/run_tests.py @@ -3,9 +3,7 @@ registry.register("db2", "ibm_db_sa.ibm_db", "DB2Dialect_ibm_db") registry.register("db2.ibm_db", "ibm_db_sa.ibm_db", "DB2Dialect_ibm_db") registry.register("db2.pyodbc", "ibm_db_sa.pyodbc", "DB2Dialect_pyodbc") -registry.register("db2.zxjdbc", "ibm_db_sa.zxjdbc", "DB2Dialect_zxjdbc") registry.register("db2.pyodbc400", "ibm_db_sa.pyodbc", "AS400Dialect_pyodbc") -registry.register("db2.zxjdbc400", "ibm_db_sa.zxjdbc", "AS400Dialect_zxjdbc") from sqlalchemy.testing import runner diff --git a/setup.py b/setup.py index ce772e2..6e6beb6 100644 --- a/setup.py +++ b/setup.py @@ -45,17 +45,13 @@ 'db2as400=ibm_db_sa.ibm_db_as400:AS400Dialect', 'db2=ibm_db_sa.ibm_db:DB2Dialect_ibm_db', 'db2.ibm_db=ibm_db_sa.ibm_db:DB2Dialect_ibm_db', - 'db2.zxjdbc=ibm_db_sa.zxjdbc:DB2Dialect_zxjdbc', 'db2.pyodbc=ibm_db_sa.pyodbc:DB2Dialect_pyodbc', - 'db2.zxjdbc400=ibm_db_sa.zxjdbc:AS400Dialect_zxjdbc', 'db2.pyodbc400=ibm_db_sa.pyodbc:AS400Dialect_pyodbc', # older "ibm_db_sa://" style for backwards # compatibility 'ibm_db_sa=ibm_db_sa.ibm_db:DB2Dialect_ibm_db', - 'ibm_db_sa.zxjdbc=ibm_db_sa.zxjdbc:DB2Dialect_zxjdbc', 'ibm_db_sa.pyodbc=ibm_db_sa.pyodbc:DB2Dialect_pyodbc', - 'ibm_db_sa.zxjdbc400=ibm_db_sa.zxjdbc:AS400Dialect_zxjdbc', 'ibm_db_sa.pyodbc400=ibm_db_sa.pyodbc:AS400Dialect_pyodbc', ] },