Use PostgreSQL inet type with DbUnit

Here's what to do when trying to set up data using DbUnit on a table with a PostgreSQL inet type defined.

environment

OSS Version
Java 7
postgresql 9.5
mybatis 3.4.2
dbunit 2.5.3

Error that occurs before action

org.dbunit.dataset.NoSuchColumnException: users.ADDR - (Non-uppercase input column: addr) The ADDR column of the table called users is inet type.

Workaround

Use the PostgresqlDataTypeFactory class The usage is as follows. I will add a class that provides Postgresql's own type to DatabaseConnection. For the implementation of getDBConnection (), refer to "I tried using Spring + Mybatis + DbUnit".

sample.java


DatabaseConnection connection = getDBConnection();
connection
    .getConfig()
    .setProperty(
        DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
        new PostgresqlDataTypeFactory()
     );
     

Recommended Posts

Use PostgreSQL inet type with DbUnit
Use PostgreSQL data type (jsonb) from Java
Use ProGuard with Gradle
Getting Started with DBUnit
Use Puphpeteer with Docker
Use XVim2 with Xcode 12.0.1
Use CentOS with LXD
Use ngrok with Docker
Use webmock with Rspec
Use PostgreSQL in Scala
Use WebJars with Gradle
Use jlink with gradle
Use Lambda Layers with Java
Use GDAL with Python with Docker
Use Thymeleaf with Azure Functions
Use pfx certificate with Okhttp3
Use Bulk API with RestHighLevelClient
Use SDKMAN! With Git Bash
Use multiple databases with Rails 6.0
Use Spring JDBC with Spring Boot
I tried UPSERT with PostgreSQL.
Use Ruby with Google Colab
Use SpatiaLite with Java / JDBC
Use log4j2 with YAML + Gradle
[Docker] Use whenever with Docker + Rails