{"record":{"id":"ee113e7a5e9634a2","repo":"pentaho/pentaho-kettle","slug":"error-getting-synonyms-from-schema","errorCode":null,"errorMessage":"Error getting synonyms from schema []","messagePattern":"Error getting synonyms from schema \\[\\]","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/Database.java","lineNumber":4471,"sourceCode":"          if ( log.isDebug() ) {\n            log.logDebug( \"Error getting synonyms for field TABLE_SCHEM (ignored): \" + e.toString() );\n          }\n        }\n\n        if ( Utils.isEmpty( schema ) ) {\n          schema = cat;\n        }\n\n        String table = alltables.getString( TABLES_META_DATA_TABLE_NAME );\n\n        if ( log.isRowLevel() ) {\n          log.logRowlevel( toString(), \"got synonym from meta-data: \"\n            + databaseMeta.getQuotedSchemaTableCombination( schema, table ) );\n        }\n        multimapPut( schema, table, synonymMap );\n      }\n    } catch ( SQLException e ) {\n      throw new KettleDatabaseException( \"Error getting synonyms from schema [\" + schemaname + \"]\", e );\n    } finally {\n      try {\n        if ( alltables != null ) {\n          alltables.close();\n        }\n      } catch ( SQLException e ) {\n        throw new KettleDatabaseException( \"Error closing resultset after getting synonyms from schema [\"\n          + schemaname + \"]\", e );\n      }\n    }\n\n    if ( log.isDetailed() ) {\n      log.logDetailed( \"read :\" + multimapSize( synonymMap ) + \" synonyms from db meta-data.\" );\n    }\n\n    return synonymMap;\n  }\n","sourceCodeStart":4453,"sourceCodeEnd":4489,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/Database.java#L4453-L4489","documentation":"Thrown when enumerating synonyms via DatabaseMetaData (Oracle-style getTables with SYNONYM type) and a SQLException occurs during iteration/fetch. Kettle wraps it in a KettleDatabaseException naming the schema. Indicates the metadata query for synonyms failed.","triggerScenarios":"Database.getSynonyms(...) call where the underlying getTables(catalog, schema, \"SYNONYM\", null) or its ResultSet.next() throws — typically on non-Oracle databases that don't support synonyms, or with a bad schema argument.","commonSituations":"Calling getSynonymMethods/getSynonyms on MySQL/PostgreSQL where SYNONYM table type is unsupported; wrong-case schema name on Oracle; user lacks dictionary privileges to list synonyms.","solutions":["Only call getSynonyms on databases that support synonyms (mainly Oracle); guard the call by database type (databaseMeta.getDatabaseInterface() instanceof OracleDatabaseMeta).","Fix the schema name case/privileges for Oracle dictionary access.","Inspect the chained SQLException cause for the driver's actual rejection reason.","Pass null schema instead of \"\" when all schemas are wanted."],"exampleFix":"// before\nString[] syns = db.getSynonymMethods(); // fails on PostgreSQL\n\n// after\nif (db.getDatabaseMeta().getDatabaseInterface() instanceof OracleDatabaseMeta) {\n  String[] syns = db.getSynonymMethods();\n}","handlingStrategy":"validation","validationCode":"boolean supportsSynonyms = db.getDatabaseMeta().getDatabaseInterface() instanceof OracleDatabaseMeta;\nif (!supportsSynonyms) return new String[0];","typeGuard":"boolean canListSynonyms(DatabaseMeta meta) {\n  return meta.getDatabaseInterface() instanceof OracleDatabaseMeta;\n}","tryCatchPattern":"try {\n  synonyms = db.getSynonyms(false, schema);\n} catch (KettleDatabaseException e) {\n  log.warn(\"Synonym listing unsupported/failed: \" + e.getCause());\n  synonyms = new String[0];\n}","preventionTips":["Only request synonyms on DBMS that support them (mainly Oracle)","Check user privileges on Oracle dictionary views","Use correct schema-name case","Inspect the cause chain before retrying"],"tags":["jdbc","database-metadata","synonyms","oracle"],"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"}