Available in versions: Dev (3.19) | Latest (3.18) | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10 | 3.9

SQL Parser

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

jOOQ includes a SQL parser API (EXPERIMENTAL in jOOQ 3.9), which allows for parsing a SQL String into a QueryPart of a specified type, including:

The current implementation of the parser is dialect agnostic and will try to parse any SQL dialect into a standard jOOQ expression tree, for instance:

// These two are the same
assertEquals(ctx.select(inline(1)), ctx.parser().parseQuery("select 1"));
assertEquals(ctx.select(inline(1)), ctx.parser().parseQuery("select 1 from dual"));

The value of such an API becomes immediately clear as the parser can consume any type of SQL string (as long as it can be represented using jOOQ API) and the generated expression tree can then be serialised again in any possible way. This can be very helpful when migrating from one database dialect to another, even without really using jOOQ as a database abstraction layer.

References to this page

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo