{"record":{"id":"0cdedf6e3be09aa6","repo":"pentaho/pentaho-kettle","slug":"error-setting-catalog-for-mdx-statement","errorCode":null,"errorMessage":"Error setting catalog for MDX statement: ''","messagePattern":"Error setting catalog for MDX statement: ''","errorType":"exception","errorClass":"OlapException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/olapinput/OlapHelper.java","lineNumber":81,"sourceCode":"\n    Class.forName( olap4jDriver );\n    OlapConnection connection = null;\n\n    if ( Utils.isEmpty( username ) && Utils.isEmpty( password ) ) {\n      connection = (OlapConnection) DriverManager.getConnection( olap4jUrl );\n    } else {\n      connection = (OlapConnection) DriverManager.getConnection( olap4jUrl, username, password );\n    }\n\n    OlapWrapper wrapper = connection;\n    olapConnection = wrapper.unwrap( OlapConnection.class );\n\n    try {\n      if ( !Utils.isEmpty( catalogName ) ) {\n        olapConnection.setCatalog( catalogName );\n      }\n    } catch ( SQLException e ) {\n      throw new OlapException( \"Error setting catalog for MDX statement: '\" + catalogName + \"'\" );\n    }\n\n    OlapStatement stmt = olapConnection.createStatement();\n\n    if ( !Utils.isEmpty( mdx ) ) {\n      CellSet tmp = stmt.executeOlapQuery( mdx );\n      result = tmp;\n    } else {\n      throw new Exception( \"Error executing empty MDX query\" );\n    }\n\n  }\n\n  public void close() throws KettleDatabaseException {\n    try {\n      if ( result != null ) {\n        result.close();\n      }","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/olapinput/OlapHelper.java#L63-L99","documentation":"OlapHelper.openQuery() sets the catalog (database) on the Mondrian/OLAP connection before executing an MDX query. If olapConnection.setCatalog(catalogName) throws a SQLException, it is rethrown as an OlapException with 'Error setting catalog for MDX statement: <catalogName>'. Note the original SQLException is not chained.","triggerScenarios":"openQuery() when the OLAP connection's setCatalog(catalogName) raises SQLException — nonexistent/misspelled catalog name, connection already closed/broken, driver rejection.","commonSituations":"Catalog name typo or catalog not deployed on the OLAP server; connection timed out or was closed before use; wrong JDBC/OLAP driver version; XMLA server not exposing the requested catalog; case-sensitivity mismatch.","solutions":["Verify the catalog name exactly matches a catalog deployed on the OLAP server (check case and spelling).","Confirm the OLAP connection is still valid — reconnect before openQuery; check the JDBC/XMLA endpoint is reachable.","Deploy the catalog (e.g. Mondrian schema) to the server or point the step at an existing catalog.","Check driver compatibility between Pentaho and the OLAP server version."],"exampleFix":"// before\nString catalogName = \"SalesCube_old\";\n// after\nString catalogName = \"SalesCube\"; // name deployed on the OLAP server","handlingStrategy":"validation","validationCode":"// Verify the catalog exists on the server before openQuery\n// e.g. query available catalogs via olapConnection.getCatalogs() and check catalogName","typeGuard":"boolean catalogExists(OlapConnection c, String name) { try { return c.getCatalogs().asIterator().stream().anyMatch(cat -> name.equals(cat.getName())); } catch (SQLException e) { return false; } }","tryCatchPattern":"try { helper.openQuery(); } catch (OlapException e) { log.error(\"Catalog setup failed for MDX: \" + e.getMessage(), e); /* validate catalog name / reconnect */ }","preventionTips":["Confirm catalog names against the OLAP server before configuring the step.","Keep the OLAP connection alive (pooling/keep-alive) to avoid closed-connection SQL errors.","Match Mondrian/olap4j driver versions with the server.","Catch OlapException early in pipelines and fail fast with a clear message."],"tags":["olap","mdx","jdbc","connection","catalog"],"backgroundTag":"database-query-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}