{"record":{"id":"b41d61247f1bd3da","repo":"apache/seatunnel","slug":"failed-to-close-s-via-jdbc","errorCode":null,"errorMessage":"Failed to close %s via JDBC.","messagePattern":"Failed to close (.+?) via JDBC\\.","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/AbstractJdbcCatalog.java","lineNumber":585,"sourceCode":"            executeInternal(defaultUrl, getCreateDatabaseSql(databaseName));\n        } catch (Exception e) {\n            throw new CatalogException(\n                    String.format(\n                            \"Failed creating database %s in catalog %s\",\n                            databaseName, this.catalogName),\n                    e);\n        }\n    }\n\n    protected void closeDatabaseConnection(String databaseName) {\n        String dbUrl = getUrlFromDatabaseName(databaseName);\n        try {\n            Connection connection = connectionMap.remove(dbUrl);\n            if (connection != null) {\n                connection.close();\n            }\n        } catch (SQLException e) {\n            throw new CatalogException(String.format(\"Failed to close %s via JDBC.\", dbUrl), e);\n        }\n    }\n\n    public void truncateTable(TablePath tablePath, boolean ignoreIfNotExists)\n            throws TableNotExistException, CatalogException {\n        checkNotNull(tablePath, \"Table path cannot be null\");\n        if (!tableExists(tablePath)) {\n            if (ignoreIfNotExists) {\n                return;\n            }\n            throw new TableNotExistException(catalogName, tablePath);\n        }\n        truncateTableInternal(tablePath);\n    }\n\n    @Override\n    public void dropDatabase(TablePath tablePath, boolean ignoreIfNotExists)\n            throws DatabaseNotExistException, CatalogException {","sourceCodeStart":567,"sourceCodeEnd":603,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/AbstractJdbcCatalog.java#L567-L603","documentation":"CatalogException thrown by closeDatabaseConnection when Connection.close() raises a SQLException. This happens during catalog shutdown/cleanup when releasing the cached connection for a given database URL.","triggerScenarios":"Calling catalog.close() (or internal closeDatabaseConnection) when the cached JDBC connection for dbUrl is already broken/aborted by the server, network was dropped, or the driver reports an error on close.","commonSituations":"Long-running job where the DB server reaped idle connections; firewall/NAT dropped the TCP session; driver bug or connection pool mismanagement; catalog closed after a prior connectivity failure.","solutions":["Inspect the wrapped SQLException; in most cases the connection is dead and can be safely discarded.","Retry close once; if it still fails, remove the connection from the pool and continue shutdown.","Enable connection keep-alive/validation queries to avoid stale connections.","Upgrade the JDBC driver if close() errors are a known issue for your version.","Treat as non-fatal during cleanup if all real work already completed."],"exampleFix":"// before\ncatalog.close(); // throws on stale connection\n// after\ntry {\n    catalog.close();\n} catch (CatalogException e) {\n    LOG.warn(\"Ignoring error closing catalog connection: {}\", e.getMessage());\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { catalog.close(); } catch (CatalogException e) { LOG.warn(\"Failed closing JDBC catalog connection (ignored): {}\", e.getMessage()); }","preventionTips":["Treat close failures during cleanup as non-fatal","Enable keep-alive/validation queries to reduce stale connections","Keep JDBC drivers up to date","Close catalogs promptly after work completes"],"tags":["jdbc","connection","cleanup","close"],"backgroundTag":"broken-pipe","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}