Class Db2MetadataHandler
- All Implemented Interfaces:
IMetadataHandler
DefaultMetadataHandler
fails with a RuntimeException.- Since:
- 2.4.7
- Version:
- $Revision$ $Date$
- Author:
- gommma (gommma AT users.sourceforge.net), Last changed by: $Author$
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanmatches(ResultSet columnsResultSet, String catalog, String schema, String table, String column, boolean caseSensitive) This method is overridden since - at least with DB2 driver db2jcc-9.5.jar - there is a problem that theDatabaseMetaDatadoes not return the same values for catalog and schema like the columnsResultSetdoes.booleanmatchesColumn(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 asIMetadataHandler.matches(ResultSet, String, String, String, String, boolean)but operating on already-extracted values instead of a liveResultSetrow.booleanWhetherResultSetTableMetaData's per-table column-metadata cache may safely useIMetadataHandler.matchesColumn(String, String, String, String, String, String, String, String, boolean)in place of the row-by-rowIMetadataHandler.matches(ResultSet, String, String, String, String, boolean)scan for this handler.Methods inherited from class org.dbunit.database.DefaultMetadataHandler
getColumns, getPrimaryKeys, getSchema, getTables, matches, tableExists
-
Constructor Details
-
Db2MetadataHandler
public Db2MetadataHandler()Default constructor.
-
-
Method Details
-
matches
public boolean matches(ResultSet columnsResultSet, String catalog, String schema, String table, String column, boolean caseSensitive) throws SQLException This method is overridden since - at least with DB2 driver db2jcc-9.5.jar - there is a problem that theDatabaseMetaDatadoes not return the same values for catalog and schema like the columnsResultSetdoes. The debugging constellation is as followscatalog="BLA", catalogName=<null> schema="BLA", schemaName="BLA"
This problem is taken into account by this metadata handler. Checks if the givenresultSetmatches the given schema and table name. The comparison is case sensitive.- Specified by:
matchesin interfaceIMetadataHandler- Overrides:
matchesin classDefaultMetadataHandler- Parameters:
columnsResultSet- A result set produced viaDatabaseMetaData.getColumns(String, String, String, String)catalog- The name of the catalog to check. Ifnullit is ignored in the comparisonschema- The name of the schema to check. Ifnullit is ignored in the comparisontable- The name of the table to check. Ifnullit is ignored in the comparisoncolumn- The name of the column to check. Ifnullit is ignored in the comparisoncaseSensitive- Whether or not the comparison should be case sensitive- Returns:
trueif the column metadata of the givenresultSetmatches the given schema and table parameters.- Throws:
SQLException- if a database access error occurs.- See Also:
-
matchesColumn
public 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 asIMetadataHandler.matches(ResultSet, String, String, String, String, boolean)but operating on already-extracted values instead of a liveResultSetrow. This lets a caller that batch-fetches and cachesDatabaseMetaData#getColumnsrows (seeResultSetTableMetaData) replay this handler's matching rules against a cached row without re-querying or holding aResultSetopen.The default implementation mirrors
DefaultMetadataHandler's matching rules. A handler whoseIMetadataHandler.matches(ResultSet, String, String, String, String, boolean)override differs must override this method the same way, and overrideIMetadataHandler.supportsColumnCache()to returntrue. Mirrorsmatches(ResultSet, String, String, String, String, boolean)'s catalog-mismatch tolerance, usingareEqualIgnoreBothNull(String, String, boolean)for the catalog comparison instead of the inherited default'sSQLHelper.areEqualIgnoreNull(String, String, boolean).- Parameters:
searchCatalog- The catalog to search for. Ifnullor empty it is ignored in the comparison.actualCatalog- The candidate row's catalog.searchSchema- The schema to search for. Ifnullor empty it is ignored in the comparison.actualSchema- The candidate row's schema.searchTable- The table to search for. Ifnullor empty it is ignored in the comparison.actualTable- The candidate row's table.searchColumn- The column to search for. Ifnullor empty it is ignored in the comparison.actualColumn- The candidate row's column.caseSensitive- Whether or not the comparison should be case sensitive.- Returns:
trueif the candidate's values match the search criteria.
-
supportsColumnCache
public boolean supportsColumnCache()WhetherResultSetTableMetaData's per-table column-metadata cache may safely useIMetadataHandler.matchesColumn(String, String, String, String, String, String, String, String, boolean)in place of the row-by-rowIMetadataHandler.matches(ResultSet, String, String, String, String, boolean)scan for this handler.Returns
falseby default, so a customIMetadataHandlerwhosematches(...)override is not also replicated inmatchesColumn(...)keeps the legacy per-column behavior. Override to returntrueonly alongside amatchesColumn(...)override that fully replicates this handler's matching semantics. The inherited defaultmatchesColumn(...)already mirrors this class'sDefaultMetadataHandler.matches(ResultSet, String, String, String, String, boolean), so the cache fast path is safe to use.- Specified by:
supportsColumnCachein interfaceIMetadataHandler- Overrides:
supportsColumnCachein classDefaultMetadataHandler- Returns:
true, sincematchesColumn(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean)replicates this class'smatches(ResultSet, String, String, String, String, boolean)semantics.
-