{"record":{"id":"f64aae13c34981b8","repo":"alibaba/druid","slug":"xa-not-support-dbtype-dbtypename","errorCode":null,"errorMessage":"xa not support dbType : {dbTypeName}","messagePattern":"xa not support dbType : (.+?)","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/alibaba/druid/pool/xa/DruidXADataSource.java","lineNumber":66,"sourceCode":"        XAConnection rawXAConnection = createPhysicalXAConnection(physicalConn);\n\n        return new DruidPooledXAConnection(conn, rawXAConnection);\n    }\n\n    protected void initCheck() throws SQLException {\n        super.initCheck();\n\n        DbType dbType = DbType.of(this.dbTypeName);\n        if (JdbcUtils.H2.equals(dbType)) {\n            h2Factory = H2Utils.createJdbcDataSourceFactory();\n        }\n    }\n\n    private XAConnection createPhysicalXAConnection(Connection physicalConn) throws SQLException {\n        DbType dbType = DbType.of(this.dbTypeName);\n\n        if (dbType == null) {\n            throw new SQLException(\"xa not support dbType : \" + this.dbTypeName);\n        }\n\n        switch (dbType) {\n            case oracle:\n                try {\n                    return OracleUtils.OracleXAConnection(physicalConn);\n                } catch (XAException xae) {\n                    LOG.error(\"create xaConnection error\", xae);\n                    return null;\n                }\n            case mysql:\n            case mariadb:\n                return MySqlUtils.createXAConnection(driver, physicalConn);\n            case postgresql:\n                return PGUtils.createXAConnection(physicalConn);\n            case h2:\n                return H2Utils.createXAConnection(h2Factory, physicalConn);\n            case jtds:","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/alibaba/druid/blob/fa8dc9912637a2f729eef9f55356621fec18d40e/core/src/main/java/com/alibaba/druid/pool/xa/DruidXADataSource.java#L48-L84","documentation":"DruidXADataSource.createPhysicalXAConnection() throws this when DbType.of(this.dbTypeName) returns null — i.e. the configured dbTypeName could not be mapped to any known DbType enum value. Because XA connection creation is dispatched per-database (Oracle, MySQL, PostgreSQL, H2, jtds, DM, OceanBase), an unrecognized dbType has no XA factory to use. This fires at the top of the switch, before any case is selected.","triggerScenarios":"Calling getXAConnection() on a DruidXADataSource whose dbTypeName is null, empty, or a value Druid cannot resolve (e.g. a misspelled or newly-introduced database name, or an unset dbType).","commonSituations":"Forgetting to set dbTypeName on DruidXADataSource; using a JDBC URL whose scheme Druid does not auto-detect to a DbType; pointing at a database (e.g. a NoSQL or unsupported engine) for which Druid has no XA support.","solutions":["Set dbTypeName explicitly to a supported value, e.g. dataSource.setDbType(\"mysql\"); supported XA types: oracle, mysql, mariadb, postgresql, h2, jtds, dm, oceanbase, oceanbase_oracle.","If your database is unsupported for XA, do not use DruidXADataSource — use the regular DruidDataSource and a non-XA transaction manager.","Print the actual dbTypeName at startup to catch null/empty/whitespace values quickly."],"exampleFix":"// before\nDruidXADataSource ds = new DruidXADataSource();\nds.setUrl(\"jdbc:mysql://db:3306/app\");\n// dbTypeName not set -> DbType.of(null) == null\nXAConnection xa = ds.getXAConnection(); // throws 'xa not support dbType : null'\n\n// after\nDruidXADataSource ds = new DruidXADataSource();\nds.setUrl(\"jdbc:mysql://db:3306/app\");\nds.setDbType(\"mysql\");\nXAConnection xa = ds.getXAConnection();","handlingStrategy":"validation","validationCode":"DruidXADataSource xa = ...;\nif (xa.getDbTypeName() == null || DbType.of(xa.getDbTypeName()) == null) {\n    throw new IllegalStateException(\"set dbTypeName to a supported value before getXAConnection()\");\n}","typeGuard":"public static boolean xaSupportedDbType(String dbTypeName) {\n    DbType t = DbType.of(dbTypeName);\n    return t != null && java.util.EnumSet.of(\n        DbType.oracle, DbType.mysql, DbType.mariadb, DbType.postgresql,\n        DbType.h2, DbType.jtds, DbType.dm, DbType.oceanbase, DbType.oceanbase_oracle\n    ).contains(t);\n}","tryCatchPattern":null,"preventionTips":["Always set dbTypeName explicitly when constructing DruidXADataSource.","Print dbTypeName at startup to catch null/empty values.","Use a non-XA DruidDataSource for unsupported databases."],"tags":["xa","datasource-configuration","dbtype","jdbc"],"backgroundTag":null,"analyzedSha":"fa8dc9912637a2f729eef9f55356621fec18d40e","analyzedAt":"2026-08-14T04:55:06.789Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}