t8y2/dbx · error · IllegalStateException

Not connected

Error message

Not connected

What it means

requireConnected is a guard used by connection-backed operations (conn, startTableRead, executeTransaction, executeBatch). It fetches the current connection and throws 'Not connected' when getConnection() returns null, i.e. no connection is currently established.

Source

Thrown at agents/common/src/main/java/com/dbx/agent/BaseDatabaseAgent.java:126

            this::resetSchemaSQL
        );
    }

    @Override
    public QueryResult executeBatch(List<String> statements, String schema) {
        return BatchExecutor.executeBatchStatements(
            requireConnected(),
            statements,
            schema,
            this::setSchemaSQL,
            this::resetSchemaSQL
        );
    }

    protected Connection requireConnected() {
        Connection conn = getConnection();
        if (conn == null) {
            throw new IllegalStateException("Not connected");
        }
        return conn;
    }

    protected static <T> T unchecked(ThrowingSupplier<T> supplier) {
        try {
            return supplier.get();
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    protected static void uncheckedVoid(ThrowingRunnable runnable) {
        unchecked(() -> {
            runnable.run();
            return null;

View on GitHub (pinned to c0390bff16)

Solutions

  1. Call connect() with valid ConnectParams before running database operations
  2. Reconnect after any close/disconnect and before retrying the operation
  3. Check the connection state (e.g. via getConnection() != null) before issuing calls
  4. Investigate why the connection was closed (timeout, error, lifecycle hook) if connect was previously called

Example fix

// before
agent.executeBatch(statements); // throws if not connected
// after
if (agent.getConnection() == null) {
    agent.connect(connectParams);
}
agent.executeBatch(statements);
Defensive patterns

Strategy: validation

Validate before calling

if (agent.getConnection() == null) {
    agent.connect(connectParams);
}
agent.executeBatch(statements);

Type guard

boolean isConnected(BaseDatabaseAgent a) {
    return a.getConnection() != null;
}

Try / catch

try {
    agent.executeTransaction(tx);
} catch (IllegalStateException e) {
    if ("Not connected".equals(e.getMessage())) {
        agent.connect(connectParams);
        agent.executeTransaction(tx);
    }
}

Prevention

When it happens

Trigger: Calling executeBatch/startTableRead/executeTransaction (or conn) before connect(), or after the connection was closed, reset, or never established due to an earlier connect failure.

Common situations: Operations issued after a dropped connection; using a shared agent from another thread after close(); forgetting to call connect in setup; lazy connection lost after timeout.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/6ecd65772dee3d8d. Report an issue: GitHub.