MySQL
Overview
org.dbunit.ext.mysql provides MySQL/MariaDB-specific type recognition and
metadata handling for dbUnit.
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.
Connection Preconfiguration Class
MySqlConnection
wraps a JDBC Connection and pre-registers both MySqlDataTypeFactory and
MySqlMetadataHandler:
IDatabaseConnection connection = new MySqlConnection(jdbcConnection, schema);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?


