Class QueryBasedSchemaInfoProvider

java.lang.Object
com.mendix.externalinterface.databaseconnector.QueryBasedSchemaInfoProvider

public abstract class QueryBasedSchemaInfoProvider extends Object
Abstract base class for providing custom SQL queries to retrieve database schema metadata in the External Database Connector.

Mendix app developers can extend this class and provide their own SQL queries for retrieving table, view, procedure and function metadata from a custom or unsupported database. The implementing class should have a public no-argument constructor.

Usage: In the External Database Connector configuration, set the "Schema Info Provider Class" to the fully qualified class name of the implementation (e.g., mymodule.MyCustomSchemaInfoProvider).

Example implementation:

public class MySchemaInfoProvider extends QueryBasedSchemaInfoProvider {

    @Override
    public String getTableMetaDataQuery() {
        return "SELECT table_name, schema_name FROM information_schema.tables WHERE table_type = 'BASE TABLE'";
    }

    @Override
    public String getViewMetaDataQuery() {
        return "SELECT table_name, schema_name FROM information_schema.views";
    }

    @Override
    public String getProcedureMetaDataQuery() {
        return "SELECT routine_name, schema_name FROM information_schema.routines WHERE routine_type = 'PROCEDURE'";
    }

    @Override
    public String getFunctionMetaDataQuery() {
        return "SELECT routine_name, schema_name FROM information_schema.routines WHERE routine_type = 'FUNCTION'";
    }
}

Each query must return a ResultSet with at least two columns in this order:

  1. The object name (table, view, procedure, or function name)
  2. The schema name
  • Constructor Details

    • QueryBasedSchemaInfoProvider

      public QueryBasedSchemaInfoProvider()
  • Method Details

    • getTableMetaDataQuery

      public abstract String getTableMetaDataQuery()
      Returns the SQL query used to retrieve table metadata.

      The query must return rows with at least:

      1. column 1: table name
      2. column 2: schema name
      Returns:
      SQL query string for table metadata
    • getViewMetaDataQuery

      public abstract String getViewMetaDataQuery()
      Returns the SQL query used to retrieve view metadata.

      The query must return rows with at least:

      1. column 1: view name
      2. column 2: schema name
      Returns:
      SQL query string for view metadata
    • getProcedureMetaDataQuery

      public abstract String getProcedureMetaDataQuery()
      Returns the SQL query used to retrieve stored procedure metadata.

      The query must return rows with at least:

      1. column 1: procedure name
      2. column 2: schema name
      Returns:
      SQL query string for procedure metadata
    • getFunctionMetaDataQuery

      public abstract String getFunctionMetaDataQuery()
      Returns the SQL query used to retrieve function metadata.

      The query must return rows with at least:

      1. column 1: function name
      2. column 2: schema name
      Returns:
      SQL query string for function metadata