MySQL

Overview

org.dbunit.ext.mysql provides MySQL-specific type recognition and metadata handling for dbUnit. See MariaDB for MariaDB, which has its own dedicated factory and reuses MySQL’s metadata handling.

IDataTypeFactory

MySqlDataTypeFactory handles several MySQL-specific mappings: longtext as CLOB, bit as BOOLEAN (MySQL 5.0+) or TINYINT depending on context, point as BINARY, and the UNSIGNED integer family (e.g. an unsigned INTEGER needs BIGINT to hold its full range without overflow — see MySQL Connector/J’s type conversion reference). Register it via DatabaseConfig.PROPERTY_DATATYPE_FACTORY — see Properties and Connections & Configuration.

IMetadataHandler

MySqlMetadataHandler fixes qualified-table-name matching (the qualified table names feature) for MySQL, where the default handler’s catalog/schema comparison doesn’t line up with how MySQL reports them. Symptom without it: a NoSuchColumnException for a column you can see exists.

For a connection not restricted to a single schema — e.g. connecting as root specifically to work across several schemas at once — use MultiSchemaMySqlMetadataHandler instead. MySQL Connector/J’s nullCatalogMeansCurrent default treats a null catalog as "the connection’s current catalog only" rather than "every catalog", so MySqlMetadataHandler alone can silently hide tables in every schema but one, surfacing as NoSuchTableException for a table you can see exists. MultiSchemaMySqlMetadataHandler works around this by enumerating and unioning results across the connection’s visible schemas itself; pair it with the qualified table names feature so same-named tables in different schemas stay distinguishable.

Connection Preconfiguration Class

MySqlConnection wraps a JDBC Connection and pre-registers both MySqlDataTypeFactory and MySqlMetadataHandler:

IDatabaseConnection connection = new MySqlConnection(jdbcConnection, schema);

Vendor-Specific Types

The longtext/bit/point/UNSIGNED handling above; otherwise standard SQL types.

Known Quirks

Forgetting to register MySqlMetadataHandler is the most common cause of a spurious NoSuchColumnException on MySQL. See the FAQ: Why am I getting a "NoSuchColumnException" but I am sure that the column actually exists?