Configurable features and properties

DbUnit does not use System properties anymore since version 2.0. DbUnit use a configuration object, DatabaseConfig, to query and set feature flags and property values for a IDatabaseConnection. It is possible to change DbUnit behaviors, such as using batched statements or not, using the getFeature, setFeature, getProperty, and setProperty methods of DatabaseConfig.

While feature flags are always boolean, property values are arbitrary objects.

The following sample displays the batched statement feature status:

  String id = "http://www.dbunit.org/features/batchedStatements"; 
  DatabaseConfig config = connection.getConfig(); 
  if (config.getFeature(id)) 
  { 
    System.out.println("Batched statements is enabled."); 
  } 
  else 
  { 
    System.out.println("Batched statements is disabled."); 
  } 

Feature Flags

Batched statements

Feature ID http://www.dbunit.org/features/batchedStatements
Default false
Description Enable or disable usage of JDBC batched statement by DbUnit.

Qualified table names

Feature ID http://www.dbunit.org/features/qualifiedTableNames
Default false
Description Enable or disable multiple schemas support. If enabled, Dbunit access tables with names fully qualified by schema using this format: SCHEMA.TABLE.
Note This feature is not compatible with the escape pattern property.

DataType warning

Feature ID http://www.dbunit.org/features/datatypeWarning
Default true
Description Enable or disable the warning message displayed when DbUnit encounter an unsupported data type.

Skip Oracle 10g Recyclebin tables

Feature ID http://www.dbunit.org/features/skipOracleRecycleBinTables
Default false
Description Enable or disable the processing of oracle recycle bin tables (tables starting with BIN$). Oracle 10g recyle bin tables may break DbUnit's assumption of tables name uniqueness within a schema since these table are case sensitive. Enable this feature for Oracle 10g databases until the bug in the oracle driver is fixed, which incorrectly reports this system tables to DbUnit.

Properties

Escape pattern

Property ID http://www.dbunit.org/properties/escapePattern
Default none
Description Allows schema, table and column names escaping. The property value is an escape pattern where the ? is replaced by the name. For example, the pattern "[?]" is expanded as "[MY_TABLE]" for a table named "MY_TABLE".
Note This property is not compatible with the qualified table names feature.

Table Type

Property ID http://www.dbunit.org/properties/tableType
Type String[]
Description Used to configure the list of table types recognized by DbUnit. See java.sql.DatabaseMetaData.getTables for possible values.
Default String[]{"TABLE"}

DataType factory

Property ID http://www.dbunit.org/properties/datatypeFactory
Default org.dbunit.dataset.datatype.DefaultDataTypeFactory
Description Used to configure the DataType factory. You can replace the default factory to add support for non-standard database vendor data types. The Object must implement org.dbunit.dataset.datatype.IDataTypeFactory .

Statement factory

Property ID http://www.dbunit.org/properties/statementFactory
Default org.dbunit.database.statement.PreparedStatementFactory
Description Used to configure the statement factory. The Object must implement org.dbunit.database.statement.IStatementFactory.

ResultSetTable factory

Property ID http://www.dbunit.org/properties/resultSetTableFactory
Default org.dbunit.database.CachedResultSetTableFactory
Description Used to configure the ResultSet table factory. The Object must implement org.dbunit.database.IResultSetTableFactory.

Primary keys filter

Property ID http://www.dbunit.org/properties/primaryKeyFilter
Default none
Description Use to override primary keys detection. The Object must implement org.dbunit.dataset.filter.IColumnFilter.

MS SQL Server IDENTITY column filter

Property ID http://www.dbunit.org/properties/mssql/identityColumnFilter
Default none
Description Use to override IDENTITY column detection. The Object must implement org.dbunit.dataset.filter.IColumnFilter.