{"record":{"id":"61d099ff7461abb5","repo":"apache/seatunnel","slug":"error-reading-default-database-charsets-e-getme","errorCode":null,"errorMessage":"Error reading default database charsets: ${e.getMessage()}","messagePattern":"Error reading default database charsets: (.+?)","errorType":"exception","errorClass":"DebeziumException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/io/debezium/connector/mysql/legacy/MySqlJdbcContext.java","lineNumber":470,"sourceCode":"                                final Map<String, DatabaseLocales> charsets = new HashMap<>();\n                                while (rs.next()) {\n                                    String dbName = rs.getString(1);\n                                    String charset = rs.getString(2);\n                                    String collation = rs.getString(3);\n                                    if (dbName != null && (charset != null || collation != null)) {\n                                        charsets.put(\n                                                dbName, new DatabaseLocales(charset, collation));\n                                        logger.debug(\n                                                \"\\t{} = {}, {}\",\n                                                Strings.pad(dbName, 45, ' '),\n                                                Strings.pad(charset, 45, ' '),\n                                                Strings.pad(collation, 45, ' '));\n                                    }\n                                }\n                                return charsets;\n                            });\n        } catch (SQLException e) {\n            throw new DebeziumException(\n                    \"Error reading default database charsets: \" + e.getMessage(), e);\n        }\n    }\n\n    protected String setStatementFor(Map<String, String> variables) {\n        StringBuilder sb = new StringBuilder(\"SET \");\n        boolean first = true;\n        List<String> varNames = new ArrayList<>(variables.keySet());\n        Collections.sort(varNames);\n        for (String varName : varNames) {\n            if (first) {\n                first = false;\n            } else {\n                sb.append(\", \");\n            }\n            sb.append(varName).append(\"=\");\n            String value = variables.get(varName);\n            if (value == null) {","sourceCodeStart":452,"sourceCodeEnd":488,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/io/debezium/connector/mysql/legacy/MySqlJdbcContext.java#L452-L488","documentation":"MySqlJdbcContext.readDatabaseCollations queries MySQL's character set/collation metadata tables (e.g. information_schema or SHOW statements) to build the default charset map. Any SQLException raised while executing those queries is wrapped in a DebeziumException with this message, keeping the original SQLException as the cause. It signals the connector could not read server charset metadata, usually due to connectivity or privilege problems.","triggerScenarios":"SQLException thrown while running the charset/collation discovery query inside readDatabaseCollations during connector startup: connection dropped mid-query, user lacks privileges on information_schema, or the query times out.","commonSituations":"MySQL user restricted by GRANTs so charset metadata tables are not readable; network/proxy dropping long connections; server restarted during startup; older MySQL variants with different metadata table layout.","solutions":["Inspect the wrapped 'cause' SQLException for the true root cause (connection refused, access denied, timeout) and fix that.","Grant the replication/connector user sufficient privileges (SELECT on information_schema, plus REPLICATION SLAVE/CLIENT for CDC).","Verify network connectivity and that MySQL is reachable from the connector host (test with mysql client).","Increase connection/query timeouts in the JDBC options if the metadata query times out on a slow server."],"exampleFix":"// before\n// user without metadata privileges\n// GRANT REPLICATION SLAVE ON *.* TO 'dbz'@'%';\n// after\nGRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'dbz'@'%';","handlingStrategy":"try-catch","validationCode":"// Pre-check MySQL reachability & privileges\ntry (Connection c = DriverManager.getConnection(url, user, pass)) {\n    c.createStatement().executeQuery(\"SELECT * FROM information_schema.COLLATIONS LIMIT 1\");\n}","typeGuard":null,"tryCatchPattern":"try { startConnector(); } catch (DebeziumException e) { logger.error(\"charset metadata read failed\", e.getCause()); throw e; }","preventionTips":["Grant the CDC user SELECT on information_schema before starting the connector.","Validate JDBC connectivity with a mysql client in CI before deploying.","Keep JDBC timeouts generous on slow networks."],"tags":["mysql","jdbc","metadata","cdc"],"backgroundTag":"database-query-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}