org.dbunit.ext.mysql
Class MySqlMetadataHandler

java.lang.Object
  extended by org.dbunit.ext.mysql.MySqlMetadataHandler
All Implemented Interfaces:
IMetadataHandler

public class MySqlMetadataHandler
extends Object
implements IMetadataHandler

Special metadata handler for MySQL.
Was introduced to fix "[ 2545095 ] Mysql FEATURE_QUALIFIED_TABLE_NAMES column SQLHelper.matches".

Since:
2.4.4
Version:
$Revision: 979 $ $Date: 2009-03-03 11:39:37 -0600 (Tue, 03 Mar 2009) $
Author:
gommma (gommma AT users.sourceforge.net), Last changed by: $Author: gommma $

Constructor Summary
MySqlMetadataHandler()
           
 
Method Summary
 ResultSet getColumns(DatabaseMetaData databaseMetaData, String schemaName, String tableName)
          Returns the result set for an invocation of DatabaseMetaData.getColumns(String, String, String, String).
 ResultSet getPrimaryKeys(DatabaseMetaData metaData, String schemaName, String tableName)
           
 String getSchema(ResultSet resultSet)
          Returns the schema name to which the table of the current result set index belongs.
 ResultSet getTables(DatabaseMetaData metaData, String schemaName, String[] tableType)
          Returns the tables in the given schema that matches one of the given tableTypes.
 boolean matches(ResultSet resultSet, String schema, String table, boolean caseSensitive)
          Checks if the given resultSet matches the given schema and table name.
 boolean matches(ResultSet columnsResultSet, String catalog, String schema, String table, String column, boolean caseSensitive)
          Checks if the given resultSet matches the given schema and table name.
 boolean tableExists(DatabaseMetaData metaData, String schema, String tableName)
          Checks if the given table exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MySqlMetadataHandler

public MySqlMetadataHandler()
Method Detail

getColumns

public ResultSet getColumns(DatabaseMetaData databaseMetaData,
                            String schemaName,
                            String tableName)
                     throws SQLException
Description copied from interface: IMetadataHandler
Returns the result set for an invocation of DatabaseMetaData.getColumns(String, String, String, String).

Specified by:
getColumns in interface IMetadataHandler
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

matches

public boolean matches(ResultSet resultSet,
                       String schema,
                       String table,
                       boolean caseSensitive)
                throws SQLException
Description copied from interface: IMetadataHandler
Checks if the given resultSet matches the given schema and table name. The comparison is case sensitive.

Specified by:
matches in interface IMetadataHandler
Parameters:
resultSet - A result set produced via DatabaseMetaData.getColumns(String, String, String, String)
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
See Also:
IMetadataHandler.matches(ResultSet, String, String, String, String, boolean)

matches

public boolean matches(ResultSet columnsResultSet,
                       String catalog,
                       String schema,
                       String table,
                       String column,
                       boolean caseSensitive)
                throws SQLException
Description copied from interface: IMetadataHandler
Checks if the given resultSet matches the given schema and table name. The comparison is case sensitive.

Specified by:
matches in interface IMetadataHandler
Parameters:
columnsResultSet - 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

getSchema

public String getSchema(ResultSet resultSet)
                 throws SQLException
Description copied from interface: IMetadataHandler
Returns the schema name to which the table of the current result set index belongs.

Specified by:
getSchema in interface IMetadataHandler
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

tableExists

public boolean tableExists(DatabaseMetaData metaData,
                           String schema,
                           String tableName)
                    throws SQLException
Description copied from interface: IMetadataHandler
Checks if the given table exists.

Specified by:
tableExists in interface IMetadataHandler
Parameters:
metaData - The database meta data
schema - 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

getTables

public ResultSet getTables(DatabaseMetaData metaData,
                           String schemaName,
                           String[] tableType)
                    throws SQLException
Description copied from interface: IMetadataHandler
Returns the tables in the given schema that matches one of the given tableTypes.

Specified by:
getTables in interface IMetadataHandler
Parameters:
metaData - The database meta data
schemaName - schema for which the tables should be retrieved; null returns all schemas
tableType - 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

getPrimaryKeys

public ResultSet getPrimaryKeys(DatabaseMetaData metaData,
                                String schemaName,
                                String tableName)
                         throws SQLException
Specified by:
getPrimaryKeys in interface IMetadataHandler
Parameters:
metaData - 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


Copyright © 2002-2012. All Rights Reserved.