{"record":{"id":"369d3ca6b84ae39c","repo":"pentaho/pentaho-kettle","slug":"error-getting-schemas","errorCode":null,"errorMessage":"Error getting schemas!","messagePattern":"Error getting schemas!","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/Database.java","lineNumber":4517,"sourceCode":"  private <K, V> int multimapSize( final Map<K, Collection<V>> map ) {\n    int count = 0;\n    for ( Collection<V> valueCollection : map.values() ) {\n      count += valueCollection.size();\n    }\n    return count;\n  }\n\n  public String[] getSchemas() throws KettleDatabaseException {\n    ArrayList<String> catalogList = new ArrayList<>();\n    ResultSet catalogResultSet = null;\n    try {\n      catalogResultSet = databaseMeta.getSchemas( getDatabaseMetaData() );\n      // Grab all the catalog names and put them in an array list\n      while ( catalogResultSet != null && catalogResultSet.next() ) {\n        catalogList.add( catalogResultSet.getString( 1 ) );\n      }\n    } catch ( SQLException e ) {\n      throw new KettleDatabaseException( \"Error getting schemas!\", e );\n    } finally {\n      try {\n        if ( catalogResultSet != null ) {\n          catalogResultSet.close();\n        }\n      } catch ( SQLException e ) {\n        throw new KettleDatabaseException( \"Error closing resultset after getting schemas!\", e );\n      }\n    }\n\n    if ( log.isDetailed() ) {\n      log.logDetailed( \"read :\" + catalogList.size() + \" schemas from db meta-data.\" );\n    }\n\n    return catalogList.toArray( new String[ catalogList.size() ] );\n  }\n\n  public String[] getCatalogs() throws KettleDatabaseException {","sourceCodeStart":4499,"sourceCodeEnd":4535,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/Database.java#L4499-L4535","documentation":"Thrown when DatabaseMetaData.getSchemas(...) fails or its ResultSet iteration raises a SQLException. Kettle wraps it as \"Error getting schemas!\" in a KettleDatabaseException. It means the database refused the schema-listing metadata request.","triggerScenarios":"Database.getSchemas() call where databaseMeta.getSchemas(getDatabaseMetaData()) throws while executing or iterating next() — driver rejects getSchemas(), connection broken, or privilege denied on system catalogs.","commonSituations":"User lacks permission to query system schema catalogs; driver (e.g. older MySQL/Informix) doesn't implement getSchemas properly; connection dropped before the call; JDBC version mismatch between driver and DB server.","solutions":["Grant the DB user read access to the system catalog/schemas (e.g. SELECT on SYS.ALL_USERS for Oracle).","Update the JDBC driver to a version that fully supports DatabaseMetaData.getSchemas().","Check connection liveness before the call and reconnect if stale.","Read the chained SQLException (getCause) for the driver's exact error message."],"exampleFix":"// before\nString[] schemas = db.getSchemas(); // user lacks catalog privileges\n\n// after\n-- grant first: GRANT SELECT ON sys.all_users TO app_user;\nString[] schemas = db.getSchemas();","handlingStrategy":"try-catch","validationCode":"if (!db.checkConnection()) { db.disconnect(); db.connect(); }\n// ensure DB user can query schema catalogs before runtime","typeGuard":null,"tryCatchPattern":"try {\n  schemas = db.getSchemas();\n} catch (KettleDatabaseException e) {\n  throw new RuntimeException(\"Schema listing failed: \" + e.getCause(), e);\n}","preventionTips":["Grant catalog/metadata read privileges to the app user","Use a current JDBC driver that implements getSchemas","Check connection health before metadata calls","Log the chained SQLException cause for diagnosis"],"tags":["jdbc","database-metadata","schemas","privileges"],"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"}