{"record":{"id":"2b67fd4ddfbbdee6","repo":"pentaho/pentaho-kettle","slug":"the-attributes-plugin-id-and-driver-class-can-t-be-both","errorCode":null,"errorMessage":"The attributes 'plugin_id' and 'driver_class' can't be both empty","messagePattern":"The attributes 'plugin_id' and 'driver_class' can't be both empty","errorType":"exception","errorClass":"KettlePluginException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/metastore/DatabaseMetaStoreUtil.java","lineNumber":193,"sourceCode":"    try {\n      element.addChild( metaStore.newAttribute( MetaStoreConst.DB_ATTR_JDBC_URL, databaseMeta.getURL() ) );\n    } catch ( Exception e ) {\n      throw new MetaStoreException( \"Unable to assemble URL from database '\" + databaseMeta.getName() + \"'\", e );\n    }\n\n    return element;\n  }\n\n  public static DatabaseMeta loadDatabaseMetaFromDatabaseElement( IMetaStore metaStore, IMetaStoreElement element ) throws KettlePluginException {\n    DatabaseMeta databaseMeta = new DatabaseMeta();\n    PluginRegistry pluginRegistry = PluginRegistry.getInstance();\n\n    // Load the appropriate database plugin (database interface)\n    //\n    String pluginId = getChildString( element, MetaStoreConst.DB_ATTR_ID_PLUGIN_ID );\n    String driverClassName = getChildString( element, MetaStoreConst.DB_ATTR_DRIVER_CLASS );\n    if ( Utils.isEmpty( pluginId ) && Utils.isEmpty( driverClassName ) ) {\n      throw new KettlePluginException( \"The attributes 'plugin_id' and 'driver_class' can't be both empty\" );\n    }\n    if ( Utils.isEmpty( pluginId ) ) {\n      // Determine pluginId using the plugin registry.\n      //\n      List<PluginInterface> plugins = pluginRegistry.getPlugins( DatabasePluginType.class );\n      for ( PluginInterface plugin : plugins ) {\n        DatabaseInterface databaseInterface = (DatabaseInterface) pluginRegistry.loadClass( plugin );\n        if ( driverClassName.equalsIgnoreCase( databaseInterface.getDriverClass() ) ) {\n          pluginId = plugin.getIds()[0];\n        }\n      }\n    }\n    if ( Utils.isEmpty( pluginId ) ) {\n      throw new KettlePluginException(\n        \"The 'plugin_id' attribute could not be determined using 'driver_class' value '\" + driverClassName + \"'\" );\n    }\n\n    // Look for the plugin","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/metastore/DatabaseMetaStoreUtil.java#L175-L211","documentation":"loadDatabaseMetaFromDatabaseElement() reconstructs a DatabaseMeta from a stored element. It needs at least one of the plugin_id (DB_ATTR_ID_PLUGIN_ID) or driver_class attributes to identify which database plugin to instantiate. If both are empty it throws KettlePluginException because the plugin cannot be determined.","triggerScenarios":"Loading a stored database element that was written without the plugin_id attribute and without a driver_class attribute.","commonSituations":"Metastore element created by hand or by a third-party tool; attributes dropped during migration; older export format missing these fields.","solutions":["Add a valid plugin_id attribute (e.g. 'MySQL', 'POSTGRESQL') to the stored element","Set the driver_class attribute (e.g. 'com.mysql.cj.jdbc.Driver') so pluginId can be derived via the registry","Re-save the connection from the UI/SDK so all required attributes are written"],"exampleFix":"// before\nelement without DB_ATTR_ID_PLUGIN_ID or DB_ATTR_DRIVER_CLASS\n// after\nelement.addChild( metaStore.newAttribute( MetaStoreConst.DB_ATTR_ID_PLUGIN_ID, \"POSTGRESQL\" ) );","handlingStrategy":"validation","validationCode":"String pluginId = DatabaseMetaStoreUtil.getChildString( element, MetaStoreConst.DB_ATTR_ID_PLUGIN_ID );\nString driver = DatabaseMetaStoreUtil.getChildString( element, MetaStoreConst.DB_ATTR_DRIVER_CLASS );\nif ( ( pluginId == null || pluginId.isEmpty() ) && ( driver == null || driver.isEmpty() ) ) {\n  throw new IllegalStateException( \"Element needs plugin_id or driver_class\" );\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write plugin_id when creating elements programmatically","Audit metastore elements for required attributes","Keep driver_class populated even when plugin_id is present"],"tags":["metastore","plugin","database-connection"],"backgroundTag":"missing-required-config-field","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"}