{"record":{"id":"2caaae88821ea2c0","repo":"cube-js/cube","slug":"ex-cause-getmessagesync","errorCode":null,"errorMessage":"ex.cause.getMessageSync()","messagePattern":"ex\\.cause\\.getMessageSync\\(\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-jdbc-driver/src/JDBCDriver.ts","lineNumber":289,"sourceCode":"  }\n\n  protected async queryPromised(query: string, cancelObj: any, options: any) {\n    options = options || {};\n\n    try {\n      const conn = await this.pool.acquire();\n      try {\n        const prepareConnectionQueries = options.prepareConnectionQueries || [];\n        for (let i = 0; i < prepareConnectionQueries.length; i++) {\n          await this.executeStatement(conn, prepareConnectionQueries[i]);\n        }\n        return await this.executeStatement(conn, query, cancelObj);\n      } finally {\n        await this.pool.release(conn);\n      }\n    } catch (ex: any) {\n      if (ex.cause) {\n        throw new Error(ex.cause.getMessageSync());\n      } else {\n        throw ex;\n      }\n    }\n  }\n\n  public async stream(sql: string, values: unknown[], { highWaterMark }: StreamOptions): Promise<DownloadQueryResultsResult> {\n    const conn = await this.pool.acquire();\n\n    try {\n      const query = this.prepareQueryWithParams(sql, values);\n      const cancelObj: {cancel?: Function} = {};\n\n      const createStatement = promisify(conn.createStatement.bind(conn));\n      const statement = await createStatement();\n\n      if (cancelObj) {\n        cancelObj.cancel = promisify(statement.cancel.bind(statement));","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-jdbc-driver/src/JDBCDriver.ts#L271-L307","documentation":"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.","triggerScenarios":"Thrown at packages/cubejs-jdbc-driver/src/JDBCDriver.ts:289 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect ex.cause (the underlying java.lang.Throwable from the JDBC bridge) via getMessageSync() to get the real database error","Fix the root cause reported by the cause message: bad credentials, invalid SQL, unreachable host, or missing connection setup statements","Re-raise with a normalized error so upper layers see a single consistent error shape"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}