cube-js/cube · error · Error

ex.cause.getMessageSync()

Error message

ex.cause.getMessageSync()

What it means

In queryPromised, JDBC exceptions from the java layer arrive wrapped; the driver surfaces ex.cause.getMessageSync() when a cause exists, so this message string is the Java-side exception message (e.g. HiveServer2/Trino/Databricks server error, connection failure, or SQL syntax error) propagated through the bridge. It indicates the executed statement failed on the remote JDBC server rather than in Cube's JavaScript layer.

Source

Thrown at packages/cubejs-jdbc-driver/src/JDBCDriver.ts:289

  }

  protected async queryPromised(query: string, cancelObj: any, options: any) {
    options = options || {};

    try {
      const conn = await this.pool.acquire();
      try {
        const prepareConnectionQueries = options.prepareConnectionQueries || [];
        for (let i = 0; i < prepareConnectionQueries.length; i++) {
          await this.executeStatement(conn, prepareConnectionQueries[i]);
        }
        return await this.executeStatement(conn, query, cancelObj);
      } finally {
        await this.pool.release(conn);
      }
    } catch (ex: any) {
      if (ex.cause) {
        throw new Error(ex.cause.getMessageSync());
      } else {
        throw ex;
      }
    }
  }

  public async stream(sql: string, values: unknown[], { highWaterMark }: StreamOptions): Promise<DownloadQueryResultsResult> {
    const conn = await this.pool.acquire();

    try {
      const query = this.prepareQueryWithParams(sql, values);
      const cancelObj: {cancel?: Function} = {};

      const createStatement = promisify(conn.createStatement.bind(conn));
      const statement = await createStatement();

      if (cancelObj) {
        cancelObj.cancel = promisify(statement.cancel.bind(statement));

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Inspect ex.cause (the underlying java.lang.Throwable from the JDBC bridge) via getMessageSync() to get the real database error
  2. Fix the root cause reported by the cause message: bad credentials, invalid SQL, unreachable host, or missing connection setup statements
  3. Re-raise with a normalized error so upper layers see a single consistent error shape
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at packages/cubejs-jdbc-driver/src/JDBCDriver.ts:289 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/2caaae88821ea2c0. Report an issue: GitHub.