Interface IMetadataHandler

All Known Implementing Classes:
Db2MetadataHandler, DefaultMetadataHandler, H2MetadataHandler, MultiSchemaMySqlMetadataHandler, MySqlMetadataHandler, NetezzaMetadataHandler

public interface IMetadataHandler
Handler to specify the behavior for a lookup of column metadata using database metadata.
Since:
2.4.4
Version:
$Revision$ $Date$
Author:
gommma (gommma AT users.sourceforge.net), Last changed by: $Author$
  • Method Details

    • getColumns

      ResultSet getColumns(DatabaseMetaData databaseMetaData, String schemaName, String tableName) throws SQLException
      Returns the result set for an invocation of DatabaseMetaData.getColumns(String, String, String, String).
      Parameters:
      databaseMetaData - The database metadata to be used for retrieving the columns
      schemaName - The schema name
      tableName - The table name
      Returns:
      The result set containing all columns
      Throws:
      SQLException - if a database access error occurs.
      Since:
      2.4.4
    • matches

      boolean matches(ResultSet resultSet, String schema, String table, boolean caseSensitive) throws SQLException
      Checks if the given resultSet matches the given schema and table name. The comparison is case sensitive.
      Parameters:
      resultSet - A result set produced via DatabaseMetaData.getColumns(String, String, String, String)
      schema - the schema name to check.
      table - the table name to check.
      caseSensitive - Whether or not the comparison should be case sensitive
      Returns:
      true if the column metadata of the given resultSet matches the given schema and table parameters.
      Throws:
      SQLException - if a database access error occurs.
      Since:
      2.4.4
      See Also:
    • matches

      boolean matches(ResultSet resultSet, String catalog, String schema, String table, String column, boolean caseSensitive) throws SQLException
      Checks if the given resultSet matches the given schema and table name. The comparison is case sensitive.
      Parameters:
      resultSet - A result set produced via DatabaseMetaData.getColumns(String, String, String, String)
      catalog - The name of the catalog to check. If null it is ignored in the comparison
      schema - The name of the schema to check. If null it is ignored in the comparison
      table - The name of the table to check. If null it is ignored in the comparison
      column - The name of the column to check. If null it is ignored in the comparison
      caseSensitive - Whether or not the comparison should be case sensitive
      Returns:
      true if the column metadata of the given resultSet matches the given schema and table parameters.
      Throws:
      SQLException - if a database access error occurs.
      Since:
      2.4.4
    • getSchema

      String getSchema(ResultSet resultSet) throws SQLException
      Returns the schema name to which the table of the current result set index belongs.
      Parameters:
      resultSet - The result set pointing to a valid record in the database that was returned by DatabaseMetaData.getTables(String, String, String, String[]).
      Returns:
      The name of the schema from the given result set
      Throws:
      SQLException - if a database access error occurs.
      Since:
      2.4.4
    • tableExists

      boolean tableExists(DatabaseMetaData databaseMetaData, String schemaName, String tableName) throws SQLException
      Checks if the given table exists.
      Parameters:
      databaseMetaData - The database meta data
      schemaName - The schema in which the table should be searched. If null the schema is not used to narrow the table name.
      tableName - The table name to be searched
      Returns:
      Returns true if the given table exists in the given schema. Else returns false.
      Throws:
      SQLException - if a database access error occurs.
      Since:
      2.4.5
    • getTables

      ResultSet getTables(DatabaseMetaData databaseMetaData, String schemaName, String[] tableTypes) throws SQLException
      Returns the tables in the given schema that matches one of the given tableTypes.
      Parameters:
      databaseMetaData - The database meta data
      schemaName - schema for which the tables should be retrieved; null returns all schemas
      tableTypes - a list of table types to include; null returns all types
      Returns:
      The ResultSet which is retrieved using DatabaseMetaData.getTables(String, String, String, String[])
      Throws:
      SQLException - if a database access error occurs.
      Since:
      2.4.5
    • getPrimaryKeys

      ResultSet getPrimaryKeys(DatabaseMetaData databaseMetaData, String schemaName, String tableName) throws SQLException
      Returns the primary keys of the given table.
      Parameters:
      databaseMetaData - The database meta data
      schemaName - schema for which the tables should be retrieved; null returns all schemas
      tableName - table for which the primary keys are retrieved
      Returns:
      The ResultSet which is retrieved using DatabaseMetaData.getPrimaryKeys(String, String, String)
      Throws:
      SQLException - if a database access error occurs.
      Since:
      2.4.5
    • matchesColumn

      default boolean matchesColumn(String searchCatalog, String actualCatalog, String searchSchema, String actualSchema, String searchTable, String actualTable, String searchColumn, String actualColumn, boolean caseSensitive)
      Tests whether a candidate column's metadata values match the search criteria, using the same semantics as matches(ResultSet, String, String, String, String, boolean) but operating on already-extracted values instead of a live ResultSet row. This lets a caller that batch-fetches and caches DatabaseMetaData#getColumns rows (see ResultSetTableMetaData) replay this handler's matching rules against a cached row without re-querying or holding a ResultSet open.

      The default implementation mirrors DefaultMetadataHandler's matching rules. A handler whose matches(ResultSet, String, String, String, String, boolean) override differs must override this method the same way, and override supportsColumnCache() to return true.

      Parameters:
      searchCatalog - The catalog to search for. If null or empty it is ignored in the comparison.
      actualCatalog - The candidate row's catalog.
      searchSchema - The schema to search for. If null or empty it is ignored in the comparison.
      actualSchema - The candidate row's schema.
      searchTable - The table to search for. If null or empty it is ignored in the comparison.
      actualTable - The candidate row's table.
      searchColumn - The column to search for. If null or empty it is ignored in the comparison.
      actualColumn - The candidate row's column.
      caseSensitive - Whether or not the comparison should be case sensitive.
      Returns:
      true if the candidate's values match the search criteria.
      Since:
      3.2.1
    • supportsColumnCache

      default boolean supportsColumnCache()
      Whether ResultSetTableMetaData's per-table column-metadata cache may safely use matchesColumn(String, String, String, String, String, String, String, String, boolean) in place of the row-by-row matches(ResultSet, String, String, String, String, boolean) scan for this handler.

      Returns false by default, so a custom IMetadataHandler whose matches(...) override is not also replicated in matchesColumn(...) keeps the legacy per-column behavior. Override to return true only alongside a matchesColumn(...) override that fully replicates this handler's matching semantics.

      Returns:
      true if this handler's cache fast path is safe to use.
      Since:
      3.2.1