MyCATApache/Mycat-Server · error · IllegalArgumentException

table name is null

Error message

table name is null

What it means

TableConfig's constructor requires a non-null tableName; it immediately throws IllegalArgumentException when tableName is null. The table name is fundamental — it is upper-cased and used as the routing key — so a null value is rejected at construction time.

Solutions

  1. Set the name attribute on the <table> element in schema.xml.
  2. If building TableConfig programmatically, pass a non-null table name string.

Example fix

// before
new TableConfig(null, "id", ...);
// after
new TableConfig(" orders", "id", ...); // non-null name, e.g. "orders"
Defensive patterns

Strategy: validation

Validate before calling

if (tableName == null || tableName.isEmpty()) throw new IllegalArgumentException("table name required");

Type guard

boolean hasName = (t != null && t.getTableName() != null && !t.getTableName().isEmpty());

Try / catch

try { TableConfig tc = new TableConfig(...); } catch (IllegalArgumentException e) { if ("table name is null".equals(e.getMessage())) { /* fix config entry */ } throw e; }

Prevention

When it happens

Trigger: Calling new TableConfig(null, ...) directly, or the XML/config loader passing a null name because the <table> element lacks a name attribute.

Common situations: A <table> entry in schema.xml missing the name attribute; programmatic config generation where the name field is left unset; reflection-based config population skipping the name property.

Related errors


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

Appendix: source

Thrown at src/main/java/io/mycat/config/model/TableConfig.java:71

    private final boolean childTable;
    private final String joinKey;
    private final String parentKey;
    private final String locateRTableKeySql;
    // only has one level of parent
    private final boolean secondLevel;
    private final boolean partionKeyIsPrimaryKey;

    private volatile List<SQLTableElement> tableElementList;
    private volatile String tableStructureSQL;
    private volatile Map<String, List<String>> dataNodeTableStructureSQLMap;
    private ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock(false);

    public TableConfig(String tableName, String primaryKey, boolean autoIncrement, boolean needAddLimit, int tableType,
                       String dataNode, Set<String> dbType, RuleConfig rule, boolean ruleRequired,
                       TableConfig parentTC, boolean isChildTable, String joinKey,
                       String parentKey, String subTables, boolean fetchStoreNodeByJdbc) {
        if (tableName == null) {
            throw new IllegalArgumentException("table name is null");
        } else if (dataNode == null) {
            throw new IllegalArgumentException("dataNode name is null");
        }
        this.primaryKey = primaryKey;
        this.autoIncrement = autoIncrement;
        this.needAddLimit = needAddLimit;
        this.fetchStoreNodeByJdbc = fetchStoreNodeByJdbc;
        this.tableType = tableType;
        this.dbTypes = dbType;
        if (ruleRequired && rule == null) {
            throw new IllegalArgumentException("ruleRequired but rule is null");
        }

        this.name = tableName.toUpperCase();
        String theDataNodes[] = SplitUtil.split(dataNode, ',', '$', '-');
        if (theDataNodes == null || theDataNodes.length <= 0) {
            throw new IllegalArgumentException("invalid table dataNodes: " + dataNode);
        }

View on GitHub (pinned to 65f8d8beb7)