MyCATApache/Mycat-Server · error · SQLSyntaxErrorException

Multi statements is not supported,use single statement…

Error message

Multi statements is not supported,use single statement instead 

What it means

Mycat's Druid-based router rejects any client SQL that contains more than one statement in a single batch. The parser (druid's parseStatementList with limit 2) is asked to parse up to two statements solely to detect batching; if more than one statement is found, routing cannot proceed because Mycat routes one statement per request. This is a deliberate restriction, not a parse failure of the SQL itself.

Solutions

  1. Split the SQL into single statements and execute them one at a time (use JDBC addBatch/executeBatch per statement instead of concatenating with ';').
  2. Remove allowMultiQueries=true from the client JDBC URL when connecting through Mycat.
  3. If you control Mycat config/code, upgrade to a version or patch that supports multi-statement, or place a proxy that splits statements before Mycat.
  4. Route around Mycat for the multi-statement connection (direct DB connection) if batching is essential.

Example fix

// before
stmt.executeUpdate("INSERT INTO t VALUES(1); INSERT INTO t VALUES(2);");
// after
try (PreparedStatement ps = conn.prepareStatement("INSERT INTO t VALUES(?)")) {
    ps.setInt(1, 1); ps.addBatch();
    ps.setInt(1, 2); ps.addBatch();
    ps.executeBatch();
}
Defensive patterns

Strategy: validation

Validate before calling

// Java
if (sql.trim().indexOf(';', sql.trim().indexOf(';') + 1) != -1) {
    throw new IllegalArgumentException("Multi-statement SQL not supported; split before sending to Mycat");
}

Type guard

boolean isSingleStatement(String sql) {
    String s = sql == null ? "" : sql.trim();
    return s.indexOf(';') == -1 || s.indexOf(';') == s.length() - 1;
}

Try / catch

try { rrs = route(sql); } catch (SQLSyntaxErrorException e) {
    if (e.getMessage().contains("Multi statements is not supported")) {
        for (String part : sql.split(";")) { if (!part.isBlank()) route(part); }
    } else throw e;
}

Prevention

When it happens

Trigger: Sending a JDBC/MySQL packet containing multiple semicolon-separated statements (e.g. 'insert into t values(1); insert into t values(2);') through Mycat when allowMultiQueries/multiStatementAllow is effectively off; the check lives in routeNormalSqlWithAST0 of DruidMycatRouteStrategy.

Common situations: JDBC batch executed with rewriteBatchedStatements or multi-statement connections; migration scripts sent as one string; ORM seeders concatenating DML; clients with allowMultiQueries=true pointed at Mycat.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11). Data as JSON: /api/errors/fceead4c31ea29fa. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/io/mycat/route/impl/DruidMycatRouteStrategy.java:137

		/**
		 * 解析出现问题统一抛SQL语法错误
		 */
		try {
            if (parser instanceof MycatStatementParser || sqlType == ServerParse.LOCK) {
                /**
                 * 说明: 1)非mysql数据库因为是jdbc驱动支持多语句,所以无需判断是否为多语句;
                 * 2)lock类型语句,因为druid自身问题且升级后mycat代码大量编译报错,只能沿用当前逻辑,不判断是否为多语句
                 */
                statement = parser.parseStatement();
            } else {
                // 因不支持多语句,添加判断是否为多语句
                List<SQLStatement> statementList = new ArrayList<SQLStatement>();

                /** 最多就解析2条,用于判断是否为批量 **/
                parser.parseStatementList(statementList, 2);
                if (statementList.size() > 1) {
                    throw new SQLSyntaxErrorException(
                            "Multi statements is not supported,use single statement instead ");
                } else {
                    statement = statementList.get(0);
                }
            }

			visitor = new MycatSchemaStatVisitor();
		} catch (Exception t) {
			LOGGER.error("DruidMycatRouteStrategyError", t);
			throw new SQLSyntaxErrorException(t);
		}

		/**
		 * 检验unsupported statement
		 */
		checkUnSupportedStatement(statement);

		DruidParser druidParser = DruidParserFactory.create(schema, statement, visitor);

View on GitHub (pinned to 65f8d8beb7)