{"record":{"id":"0da621d76b4a726c","repo":"pentaho/pentaho-kettle","slug":"mysqldatabasemeta-exception","errorCode":"MySQLDatabaseMeta.Exception.LegacyColumnNameNoDBMetaDataException","errorMessage":"MySQLDatabaseMeta.Exception.LegacyColumnNameNoDBMetaDataException (localized via BaseMessages)","messagePattern":"MySQLDatabaseMeta\\.Exception\\.LegacyColumnNameNoDBMetaDataException \\(localized via BaseMessages\\)","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/MariaDBDatabaseMeta.java","lineNumber":64,"sourceCode":"  }\n\n  @Override public boolean fullExceptionLog( Exception e ) {\n    Throwable cause = ( e == null ? null : e.getCause() );\n    return !( cause != null && SHORT_MESSAGE_EXCEPTIONS.contains( cause.getClass().getName() ) );\n  }\n\n  /**\n   * Returns the column name for a MariaDB field.\n   *\n   * @param dbMetaData\n   * @param rsMetaData\n   * @param index\n   * @return The column label.\n   * @throws KettleDatabaseException\n   */\n  @Override public String getLegacyColumnName( DatabaseMetaData dbMetaData, ResultSetMetaData rsMetaData, int index ) throws KettleDatabaseException {\n    if ( dbMetaData == null ) {\n      throw new KettleDatabaseException( BaseMessages.getString( PKG, \"MySQLDatabaseMeta.Exception.LegacyColumnNameNoDBMetaDataException\" ) );\n    }\n\n    if ( rsMetaData == null ) {\n      throw new KettleDatabaseException( BaseMessages.getString( PKG, \"MySQLDatabaseMeta.Exception.LegacyColumnNameNoRSMetaDataException\" ) );\n    }\n\n    try {\n      return rsMetaData.getColumnLabel( index );\n    } catch ( Exception e ) {\n      throw new KettleDatabaseException( String.format( \"%s: %s\", BaseMessages.getString( PKG, \"MySQLDatabaseMeta.Exception.LegacyColumnNameException\" ), e.getMessage() ), e );\n    }\n  }\n}\n","sourceCodeStart":46,"sourceCodeEnd":78,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/MariaDBDatabaseMeta.java#L46-L78","documentation":"Thrown by MariaDBDatabaseMeta.getLegacyColumnName when the JDBC DatabaseMetaData argument is null. The method resolves a legacy column name/label from result set metadata, which requires the database metadata (e.g. driver version checks) to be present, so a null argument is treated as a programming/configuration error and wrapped in a KettleDatabaseException with a localized message.","triggerScenarios":"Calling getLegacyColumnName(dbMetaData=null, rsMetaData, index) — typically when a caller obtained no DatabaseMetaData from a Connection (e.g. connection closed or getMetaData() returned null) and passes it straight through.","commonSituations":"Custom database plugin or fork code invoking the legacy column-name API without first acquiring DatabaseMetaData; a broken/closed JDBC connection returning null metadata; mocking frameworks injecting null metadata in tests.","solutions":["Ensure the java.sql.Connection is open and call connection.getMetaData() before invoking getLegacyColumnName, aborting early if it returns null","Check the caller that produced the DatabaseMetaData — fix it to propagate a real connection instead of null","If metadata is genuinely unavailable, fall back to ResultSetMetaData-only logic or skip legacy name resolution rather than calling this method"],"exampleFix":"// before\nString label = meta.getLegacyColumnName(null, rsMetaData, index);\n// after\nDatabaseMetaData dbMetaData = connection.getMetaData();\nif (dbMetaData != null) {\n  String label = meta.getLegacyColumnName(dbMetaData, rsMetaData, index);\n}","handlingStrategy":"type-guard","validationCode":"DatabaseMetaData dbMeta = connection != null ? connection.getMetaData() : null;\nif (dbMeta == null) throw new IllegalStateException(\"No DatabaseMetaData: connection closed or invalid\");","typeGuard":"function hasDbMetaData(Connection c) { try { return c != null && c.getMetaData() != null; } catch (SQLException e) { return false; } }","tryCatchPattern":"try {\n  String label = meta.getLegacyColumnName(dbMetaData, rsMetaData, index);\n} catch (KettleDatabaseException e) {\n  log.error(\"No DB metadata available for legacy column lookup\", e);\n}","preventionTips":["Always obtain DatabaseMetaData from an open, validated Connection","Null-check metadata at the call boundary before legacy APIs","Keep connections alive for the duration of metadata operations"],"tags":["jdbc","null-argument","metadata","database"],"backgroundTag":"null-argument","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"}