25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(jdbc): tolerate AbstractMethodError from legacy getSchemas drivers
Thanadon Kongkanun124093eca94d
diff --git a/plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java b/plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.javaindex 54caf380ba..ae6baf6332 100644--- a/plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java+++ b/plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java@@ -2297,27 +2297,33 @@ public final class DbxJdbcPlugin {if (quirks.caseInsensitiveSchemaMetadata()) {try (ResultSet rs = meta.getSchemas(catalog, null)) {appendSchemas(result, rs, true);- } catch (SQLException ignored) {+ } catch (SQLException | AbstractMethodError ignored) {+ // Legacy/incomplete JDBC drivers (e.g. jTDS against SQL Server 2000, #11127)+ // throw AbstractMethodError instead of a proper SQLException when their+ // getSchemas(String, String) implementation is incomplete.try (ResultSet rs = meta.getSchemas()) {appendSchemas(result, rs, true);+ } catch (AbstractMethodError ignored2) {}}try (ResultSet rs = meta.getSchemas(null, null)) {appendSchemas(result, rs, true);- } catch (SQLException ignored) {+ } catch (SQLException | AbstractMethodError ignored) {}} else {try (ResultSet rs = meta.getSchemas(catalog, null)) {appendSchemas(result, rs, false);- } catch (SQLFeatureNotSupportedException | UnsupportedOperationException ignored) {+ } catch (SQLFeatureNotSupportedException | UnsupportedOperationException | AbstractMethodError ignored) {+ // See the AbstractMethodError note above: same legacy-driver fallback.try (ResultSet rs = meta.getSchemas()) {appendSchemas(result, rs, false);+ } catch (AbstractMethodError ignored2) {}}if (result.isEmpty() && catalog != null) {try (ResultSet rs = meta.getSchemas(null, null)) {appendSchemas(result, rs, false);- } catch (SQLFeatureNotSupportedException | UnsupportedOperationException ignored) {+ } catch (SQLFeatureNotSupportedException | UnsupportedOperationException | AbstractMethodError ignored) {}}}diff --git a/plugins/jdbc/src/test/java/app/dbx/jdbc/DbxJdbcPluginTest.java b/plugins/jdbc/src/test/java/app/dbx/jdbc/DbxJdbcPluginTest.javaindex 1302667d01..d4f4e3b256 100644--- a/plugins/jdbc/src/test/java/app/dbx/jdbc/DbxJdbcPluginTest.java+++ b/plugins/jdbc/src/test/java/app/dbx/jdbc/DbxJdbcPluginTest.java@@ -2992,6 +2992,39 @@ final class DbxJdbcPluginTest {}}+ @Test+ void listSchemasDegradesToEmptyWhenDriverRejectsSchemaMetadata() throws Exception {+ // #11127: jTDS against SQL Server 2000 throws AbstractMethodError (not a proper+ // SQLException) from DatabaseMetaData.getSchemas(String, String) because its+ // implementation predates that JDBC overload. Clicking a table/database in the+ // sidebar must degrade gracefully instead of failing the whole connection.+ for (Throwable failure : List.of(+ new SQLFeatureNotSupportedException("schemas not supported"),+ new UnsupportedOperationException("unsupported"),+ new AbstractMethodError("unsupported")+ )) {+ String connection = """+ { "connection_string": "jdbc:dbx-schema-metadata:%s" }+ """.formatted(failure.getClass().getSimpleName());+ Driver driver = testDriver("jdbc:dbx-schema-metadata:", schemaMetadataConnection(failure));+ DriverManager.registerDriver(driver);+ try {+ JsonNode response = request("listSchemas", """+ {+ "connection": %s,+ "database": "public"+ }+ """.formatted(connection));++ assertFalse(response.has("error"), failure.getClass().getSimpleName() + ": " + response);+ assertEquals(true, response.path("result").isArray(), failure.getClass().getSimpleName() + ": " + response);+ assertEquals(0, response.path("result").size(), failure.getClass().getSimpleName() + ": " + response);+ } finally {+ closeAndDeregister(connection, driver);+ }+ }+ }+@Testvoid oracleListSchemasFallsBackToJdbcSchemasWhenAllUsersIsMissing() throws Exception {Method method = DbxJdbcPlugin.class.getDeclaredMethod("oracleListSchemas", Connection.class);@@ -3951,6 +3984,41 @@ final class DbxJdbcPluginTest {);}+ private static Connection schemaMetadataConnection(Throwable failure) {+ ResultSet emptySchemas = (ResultSet) Proxy.newProxyInstance(+ DbxJdbcPluginTest.class.getClassLoader(),+ new Class<?>[] { ResultSet.class },+ (proxy, method, args) -> switch (method.getName()) {+ case "next" -> false;+ case "close" -> null;+ default -> defaultValue(method.getReturnType());+ }+ );+ DatabaseMetaData metadata = (DatabaseMetaData) Proxy.newProxyInstance(+ DbxJdbcPluginTest.class.getClassLoader(),+ new Class<?>[] { DatabaseMetaData.class },+ (proxy, method, args) -> {+ if ("getSchemas".equals(method.getName()) && args != null && args.length == 2) {+ throw failure;+ }+ if ("getSchemas".equals(method.getName())) {+ return emptySchemas;+ }+ return defaultValue(method.getReturnType());+ }+ );+ return (Connection) Proxy.newProxyInstance(+ DbxJdbcPluginTest.class.getClassLoader(),+ new Class<?>[] { Connection.class },+ (proxy, method, args) -> switch (method.getName()) {+ case "getMetaData" -> metadata;+ case "isClosed" -> false;+ case "close" -> null;+ default -> defaultValue(method.getReturnType());+ }+ );+ }+private static Connection transactionMetadataConnection(Throwable metadataFailure, boolean supportsTransactions) {boolean[] autoCommit = { true };DatabaseMetaData metadata = (DatabaseMetaData) Proxy.newProxyInstance(