SQL to jOOQ Generator

Convert SQL CREATE TABLE statements to jOOQ Java code with Table and Field definitions for type-safe SQL queries.

What is SQL to jOOQ Generator?

jOOQ (Java Object Oriented Querying) is a Java library that generates type-safe SQL by producing Java code from your database schema. Unlike ORMs that abstract away SQL, jOOQ embraces it — you write SQL in Java using generated table and field constants, and the compiler catches typos and type mismatches before runtime. This converter takes your SQL CREATE TABLE statements and generates Java code including a Tables class with SCREAMING_SNAKE_CASE table and field constants, plus Record classes with typed getters and setters for each table.

How to Use

  1. Paste your SQL CREATE TABLE statements into the input area
  2. Click "Generate" to produce jOOQ Java code with Table constants, Field constants, and Record classes
  3. Copy the output and save it as a .java file in your jOOQ generated code package
  4. Use the generated Table and Field constants in your jOOQ queries for compile-time type safety
  5. Import org.jooq.impl.DSL and use the constants with DSL.select(), DSL.insertInto(), etc.

Why Use This Tool?

Generates Table constants and typed Field constants that jOOQ uses for compile-time query verification
SQL types are mapped to Java types automatically — String for VARCHAR/TEXT, Long for INTEGER/BIGINT, Boolean for BOOLEAN, LocalDate/LocalDateTime for DATE/TIMESTAMP, UUID for UUID, byte[] for BLOB
Record classes with typed getters and setters provide an ORM-like layer on top of jOOQ table references
Field names follow SCREAMING_SNAKE_CASE convention (e.g., USER_ID, POST_CREATED_AT) matching jOOQ code generation standards
The generated code uses org.jooq.impl.DSL static imports for clean, fluent query building

Tips & Best Practices

  • Table and field constants use SCREAMING_SNAKE_CASE by convention — USER for a users table, USER_ID for the id column
  • Use the generated constants with jOOQ DSL: dsl.selectFrom(Tables.USER).where(Tables.USER_ID.eq(1L)).fetch()
  • Record classes extend TableRecordImpl and provide type-safe access to row data through getValue() and setValue()
  • For production projects, prefer jOOQ built-in code generation (mvn jooq-codegen:generate) which connects to your live database for maximum accuracy

Frequently Asked Questions

How are SQL types mapped to Java types in jOOQ?

VARCHAR/TEXT/LONGTEXT map to String, INTEGER/BIGINT/SERIAL map to Long, SMALLINT maps to Short, FLOAT/DOUBLE/DECIMAL map to Double, BOOLEAN maps to Boolean, DATE maps to LocalDate, TIME maps to LocalTime, TIMESTAMP maps to LocalDateTime, UUID maps to UUID, BLOB/BINARY map to byte[], YEAR maps to Short.

When should I avoid using jOOQ?

jOOQ requires a commercial license for databases other than PostgreSQL, MySQL, and SQLite. Avoid it if your project cannot use the jOOQ commercial edition with Oracle or SQL Server, if you prefer a full ORM with change tracking (consider Hibernate instead), or if you need a lightweight solution without code generation overhead (consider JDBI or Spring JDBC).

What is the naming convention for generated code?

Table and field names are converted to SCREAMING_SNAKE_CASE. A table named user_profiles becomes USER_PROFILES, and a column named created_at becomes USER_PROFILES_CREATED_AT. This matches jOOQ official code generation output and makes constants easy to identify in code.

How do I use the generated code in queries?

Import the Tables class and use the constants with jOOQ DSL methods. Example: dsl.selectFrom(Tables.USER).where(Tables.USER_ID.eq(1L)).fetchOne() returns a typed record. For inserts: dsl.insertInto(Tables.USER).set(Tables.USER_NAME, "Alice").execute().

Is my SQL data sent to a server?

No. All parsing and code generation runs entirely in your browser. Your SQL schema is never transmitted over the network, and no external services are contacted during the conversion process.

Real-world Examples

Spring Boot service with jOOQ queries

A Java developer building a Spring Boot microservice pastes their PostgreSQL schema into this tool, generates jOOQ table and field constants, and uses them to build type-safe queries in their repository layer. The compiler catches any column name or type mismatches before the code runs.

Input
CREATE TABLE events (
  id SERIAL PRIMARY KEY,
  name VARCHAR(200) NOT NULL,
  event_date DATE NOT NULL,
  capacity INTEGER DEFAULT 100,
  created_at TIMESTAMP DEFAULT NOW()
);
Output
public static final Table<Record> EVENTS = table("events");
public static final Field<Long> EVENTS_ID = field("events.id", Long.class);
public static final Field<String> EVENTS_NAME = field("events.name", String.class);
public static final Field<LocalDate> EVENTS_EVENT_DATE = field("events.event_date", LocalDate.class);

Rapid prototyping before full jOOQ codegen

A team evaluates jOOQ for their project by using this converter to generate initial Java code from their schema, then later switches to jOOQ built-in code generation that connects to their running database for production-grade output.

Related Tools