Loading (the Loader API)
Whenever we need to load (import) our database tables with data coming from different sources (CSV, JSON, and so on), we can rely on the jOOQ Loader API (org.jooq.Loader
). This is a fluent API that allows us to smoothly tackle the most important challenges, such as handling duplicate keys, bulking, batching, committing, and error handling.
The Loader API syntax
Typically, we have a file containing the data to be imported in a common format such as CSV or JSON, and we customize the Loader API general syntax to fit our needs:
ctx.loadInto(TARGET_TABLE) .[options] .[source and source to target mapping] .[listeners] .[execution and error handling]
While TARGET_TABLE
is obviously the table in which the data should be imported, let's see what options we have.
Options
We can mainly distinguish between three types of options that can be used for customizing the import process...