pentaho/pentaho-kettle · error · MetaStoreException

Unable to find the database connection type

Error message

Unable to find the database connection type

What it means

After confirming the namespace exists, populateDatabaseElement() looks up the element type named PentahoDefaults.DATABASE_CONNECTION_ELEMENT_TYPE_NAME. If the metastore has no such element type it throws this MetaStoreException. The database-connection element type must be registered in the namespace before elements can be created.

Solutions

  1. Call DatabaseMetaStoreUtil.populateDatabaseElementType( metaStore ) to create/ensure the element type
  2. Verify with metaStore.getElementTypeByName( PentahoDefaults.NAMESPACE, PentahoDefaults.DATABASE_CONNECTION_ELEMENT_TYPE_NAME ) before storing
  3. Re-run metastore initialization for the namespace

Example fix

// before
metaStore.createNamespace( PentahoDefaults.NAMESPACE ); // namespace only, no type
// after
metaStore.createNamespace( PentahoDefaults.NAMESPACE );
DatabaseMetaStoreUtil.populateDatabaseElementType( metaStore );
Defensive patterns

Strategy: validation

Validate before calling

if ( metaStore.getElementTypeByName( PentahoDefaults.NAMESPACE,
    PentahoDefaults.DATABASE_CONNECTION_ELEMENT_TYPE_NAME ) == null ) {
  DatabaseMetaStoreUtil.populateDatabaseElementType( metaStore );
}

Prevention

When it happens

Trigger: Calling populateDatabaseElement()/databaseElement() where the namespace exists but getElementTypeByName(namespace, DATABASE_CONNECTION_ELEMENT_TYPE_NAME) returns null — the type was never created or was deleted.

Common situations: Namespace created manually without registering the database-connection element type; metastore partially initialized; type definition changed between product versions.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/975b8e241ecac07b. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/metastore/DatabaseMetaStoreUtil.java:119

    //
    elementType.setName( PentahoDefaults.DATABASE_CONNECTION_ELEMENT_TYPE_NAME );
    elementType.setDescription( PentahoDefaults.DATABASE_CONNECTION_ELEMENT_TYPE_DESCRIPTION );
    return elementType;
  }

  public static IMetaStoreElement populateDatabaseElement( IMetaStore metaStore, DatabaseMeta databaseMeta ) throws MetaStoreException {

    if ( !metaStore.namespaceExists( PentahoDefaults.NAMESPACE ) ) {
      throw new MetaStoreException( "Namespace '" + PentahoDefaults.NAMESPACE + "' doesn't exist." );
    }

    // If the data type doesn't exist, error out...
    //
    IMetaStoreElementType elementType =
      metaStore.getElementTypeByName(
        PentahoDefaults.NAMESPACE, PentahoDefaults.DATABASE_CONNECTION_ELEMENT_TYPE_NAME );
    if ( elementType == null ) {
      throw new MetaStoreException( "Unable to find the database connection type" );
    }

    elementType = populateDatabaseElementType( metaStore );

    // generate a new database element and populate it with metadata
    //
    IMetaStoreElement element = metaStore.newElement( elementType, databaseMeta.getName(), null );

    element.addChild( metaStore.newAttribute( MetaStoreConst.DB_ATTR_ID_PLUGIN_ID, databaseMeta.getPluginId() ) );

    element.setName( databaseMeta.getName() );

    element.addChild( metaStore
      .newAttribute( MetaStoreConst.DB_ATTR_ID_DESCRIPTION, databaseMeta.getDescription() ) );
    element.addChild( metaStore.newAttribute( MetaStoreConst.DB_ATTR_ID_ACCESS_TYPE, databaseMeta
      .getAccessTypeDesc() ) );
    element.addChild( metaStore.newAttribute( MetaStoreConst.DB_ATTR_ID_HOSTNAME, databaseMeta.getHostname() ) );
    element.addChild( metaStore.newAttribute( MetaStoreConst.DB_ATTR_ID_PORT, databaseMeta

View on GitHub (pinned to f3058517a1)