{"record":{"id":"e98f535b4c055dce","repo":"apache/seatunnel","slug":"couldn-t-obtain-encoding-for-database-database","errorCode":null,"errorMessage":"Couldn't obtain encoding for database <database>","messagePattern":"Couldn't obtain encoding for database <database>","errorType":"exception","errorClass":"DebeziumException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-opengauss/src/main/java/io/debezium/connector/postgresql/connection/PostgresConnection.java","lineNumber":603,"sourceCode":"                                            + \", create role: \"\n                                            + rs.getBoolean(5)\n                                            + \", create db: \"\n                                            + rs.getBoolean(6)\n                                            + \", can log in: \"\n                                            + rs.getBoolean(7);\n                            String roleName = rs.getString(2);\n                            serverInfo.addRole(roleName, roleInfo);\n                        }\n                    });\n        }\n        return serverInfo;\n    }\n\n    public Charset getDatabaseCharset() {\n        try {\n            return Charset.forName(((BaseConnection) connection()).getEncoding().name());\n        } catch (SQLException e) {\n            throw new DebeziumException(\"Couldn't obtain encoding for database \" + database(), e);\n        }\n    }\n\n    public TimestampUtils getTimestampUtils() {\n        try {\n            return ((PgConnection) this.connection()).getTimestampUtils();\n        } catch (SQLException e) {\n            throw new DebeziumException(\n                    \"Couldn't get timestamp utils from underlying connection\", e);\n        }\n    }\n\n    private static void validateServerVersion(Statement statement) throws SQLException {}\n\n    @Override\n    public String quotedColumnIdString(String columnName) {\n        if (columnName.contains(\"\\\"\")) {\n            columnName = columnName.replaceAll(\"\\\"\", \"\\\"\\\"\");","sourceCodeStart":585,"sourceCodeEnd":621,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-opengauss/src/main/java/io/debezium/connector/postgresql/connection/PostgresConnection.java#L585-L621","documentation":"getDatabaseCharset obtains the connection encoding from the underlying JDBC connection's Encoding via ((BaseConnection) connection()).getEncoding().name() and wraps any SQLException in a DebeziumException with this message. The charset is needed to build the value converter, so failing to read it stops connector initialization.","triggerScenarios":"The cast to PgConnection's BaseConnection succeeds but getEncoding() throws SQLException — usually because the underlying connection is closed/broken, or the driver cannot resolve the server's encoding name to a Java charset.","commonSituations":"Connection dropped between establishment and schema initialization (network blip, server restart); unsupported server encoding name (e.g. SQL_ASCII variants the JDBC driver cannot map); non-standard OpenGauss wire behavior.","solutions":["Check network/server health and restart the connector so a fresh connection is created.","Ensure the database encoding is one the JDBC driver supports: SHOW server_encoding; (prefer UTF8 over SQL_ASCII).","Recreate the database or convert its encoding: CREATE DATABASE db WITH ENCODING 'UTF8' TEMPLATE template0.","Confirm connector and JDBC driver versions are compatible with the server (OpenGauss vs PostgreSQL)."],"exampleFix":"-- before: database created with unsupported encoding\nSHOW server_encoding; -- SQL_ASCII\n-- after\nCREATE DATABASE mydb WITH ENCODING 'UTF8' TEMPLATE template0;","handlingStrategy":"validation","validationCode":"SHOW server_encoding; -- should return a JDBC-driver-supported encoding like UTF8","typeGuard":null,"tryCatchPattern":"try {\n    Charset cs = connection.getDatabaseCharset();\n} catch (DebeziumException e) {\n    // underlying connection broken or unsupported encoding: recreate connection / fix DB encoding\n}","preventionTips":["Create databases with UTF8 encoding.","Avoid SQL_ASCII databases for CDC workloads.","Ensure stable network connectivity during connector initialization."],"tags":["cdc","postgres","encoding","jdbc"],"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"}